Top Description Fields Constructors Methods
io.rsocket.internal.jctools.queues

pack-priv final Class Pow2

extends Object
Class Inheritance

Power of 2 utility functions.

Field Summary

Modifier and TypeField and Description
public static final int

Constructor Summary

AccessConstructor and Description
pack-priv
Pow2()

Method Summary

Modifier and TypeMethod and Description
public static long

Returns:

the value aligned to the next boundary.
align
(final long
to be aligned up.
value
,
final int
to be used, must be a power of 2.
alignment
)

Align a value to the next multiple up of alignment.

public static boolean

Returns:

true if the value is a power of 2 otherwise false.
isPowerOfTwo
(final int
to be tested to see if it is a power of two.
value
)

public static int

Returns:

the next positive power of 2, this value if it is a power of 2. Negative values are mapped to 1.
roundToPowerOfTwo
(final int
from which next positive power of two will be found.
value
)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MAX_POW2back to summary
public static final int MAX_POW2

Constructor Detail

Pow2back to summary
pack-priv Pow2()

Method Detail

alignback to summary
public static long align(final long value, final int alignment)

Align a value to the next multiple up of alignment. If the value equals an alignment multiple then it is returned unchanged.

Parameters
value:long

to be aligned up.

alignment:int

to be used, must be a power of 2.

Returns:long

the value aligned to the next boundary.

isPowerOfTwoback to summary
public static boolean isPowerOfTwo(final int value)
Parameters
value:int

to be tested to see if it is a power of two.

Returns:boolean

true if the value is a power of 2 otherwise false.

roundToPowerOfTwoback to summary
public static int roundToPowerOfTwo(final int value)
Parameters
value:int

from which next positive power of two will be found.

Returns:int

the next positive power of 2, this value if it is a power of 2. Negative values are mapped to 1.

Exceptions
IllegalArgumentException:
is value is more than MAX_POW2 or less than 0