Constructor and Description |
---|
Bitfield.Util() |
Modifier and Type | Method and Description |
---|---|
static 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:
|
static int |
getBitMask(int n)
Returns the 32 bit mask of n-bits, i.e.
|
public static int getBitMask(int n)
Implementation handles n == 32.
IndexOutOfBoundsException
- if b
is out of bounds, i.e. > 32public static final int bitCount(int n)
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/