/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jctools.util;

/**
 * Power of 2 utility functions.
 */
public class Pow2 {

    /**
     * Find the next larger positive power of two value up from the given value. If value is a power of two then
     * this value will be returned.
     *
     * @param value from which next positive power of two will be found.
     * @return the next positive power of 2 or this value if it is a power of 2.
     */
    public static int roundToPowerOfTwo(final int value) {
        return 1 << (32 - Integer.numberOfLeadingZeros(value - 1));
    }

    /**
     * Is this value a power of two.
     *
     * @param value to be tested to see if it is a power of two.
     * @return true if the value is a power of 2 otherwise false.
     */
    public static boolean isPowerOfTwo(final int value) {
        return (value & (value - 1)) == 0;
    }
}

@@ -626,16 +626,22 @@
 %0Apublic 
+final 
 class Po
@@ -644,16 +644,43 @@
 s Pow2 %7B
+%0A    private Pow2() %7B%0A    %7D
 %0A%0A    /*
@@ -797,20 +797,20 @@
 then
+ this
 %0A     *
- this
  val
@@ -1430,11 +1430,608 @@
 0;%0A    %7D
+%0A%0A    /**%0A     * Align a value to the next multiple up of alignment. If the value equals an alignment multiple then it is returned%0A     * unchanged.%0A     * %0A     * @param value to be aligned up.%0A     * @param alignment to be used, must be a power of 2.%0A     * @return the value aligned to the next boundary.%0A     */%0A    public static long align(final long value, final int alignment) %7B%0A        if (!isPowerOfTwo(alignment)) %7B%0A            throw new IllegalArgumentException(%22alignment must be a power of 2:%22 + alignment);%0A        %7D%0A        return (value + (alignment - 1)) & ~(alignment - 1);%0A    %7D
 %0A%7D%0A

Add an align method