|
GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java (public API).
|
Bit operation utilities (static). More...
Static Public Member Functions | |
| static int | getBitMask (final int n) |
| Returns the 32 bit mask of n-bits, i.e. More... | |
| static final int | bitCount (int n) |
| Returns the number of set bits within given 32bit integer in O(1) using a HAKEM 169 Bit Count inspired implementation: More... | |
| static final boolean | isPowerOf2 (final int n) |
Returns true if the given integer is a power of 2. More... | |
| static final int | nextPowerOf2 (int n) |
Returns the next higher power of 2 of 32-bit of given n @endiliteral. More... | |
| static final int | roundToPowerOf2 (final int n) |
If the given n is not isPowerOf2(int) return nextPowerOf2(int), otherwise return n unchanged. More... | |
Static Public Attributes | |
| static final int | MAX_POWER_OF_2 = 1 << ( Integer.SIZE - 2 ) |
Maximum 32bit integer value being of isPowerOf2(int). More... | |
Bit operation utilities (static).
Definition at line 43 of file Bitfield.java.
|
static |
Returns the number of set bits within given 32bit integer in O(1) using a HAKEM 169 Bit Count inspired implementation:
http://www.inwap.com/pdp10/hbaker/hakmem/hakmem.html http://home.pipeline.com/~hbaker1/hakmem/hacks.html#item169 http://tekpool.wordpress.com/category/bit-count/ http://www.hackersdelight.org/
<p<blockquote>
We rely on the JVM spec Integer#SIZE == 32.
Definition at line 82 of file Bitfield.java.
|
static |
Returns the 32 bit mask of n-bits, i.e.
n low order 1’s.
Implementation handles n == 32.
| IndexOutOfBoundsException | if b is out of bounds, i.e. > 32 |
Definition at line 59 of file Bitfield.java.
|
static |
Returns true if the given integer is a power of 2.
Source: bithacks: http://www.graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2
Definition at line 108 of file Bitfield.java.
|
static |
Returns the next higher power of 2 of 32-bit of given n @endiliteral.
Source: bithacks: http://www.graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
We rely on the JVM spec Integer#SIZE == 32.
Definition at line 120 of file Bitfield.java.
|
static |
If the given n is not isPowerOf2(int) return nextPowerOf2(int), otherwise return n unchanged.
return isPowerOf2(n) ? n : nextPowerOf2(n);
<p<blockquote>
We rely on the JVM spec Integer#SIZE == 32.
Definition at line 139 of file Bitfield.java.
|
static |
Maximum 32bit integer value being of isPowerOf2(int).
We rely on the JVM spec Integer#SIZE == 32.
Definition at line 50 of file Bitfield.java.