28package com.jogamp.common.util;
30import jogamp.common.util.SyncedBitfield;
61 return ( 1 << n ) - 1;
62 }
else if ( 32 == n ) {
65 throw new IndexOutOfBoundsException(
"n <= 32 expected, is "+n);
94 n = n - ((n >>> 1) & 0x55555555);
95 n = (n & 0x33333333) + ((n >>> 2) & 0x33333333);
96 n = (n + (n >>> 4)) & 0x0f0f0f0f;
109 return 0<n && 0 == (n & (n - 1));
127 return (n < 0) ? 1 : n + 1;
155 if( 32 >= storageBitSize ) {
156 return new jogamp.common.util.Int32Bitfield();
158 return new jogamp.common.util.Int32ArrayBitfield(storageBitSize);
165 return new SyncedBitfield(impl);
187 int get32(
final int lowBitnum,
final int length)
throws IndexOutOfBoundsException;
198 void put32(
final int lowBitnum,
final int length,
final int data)
throws IndexOutOfBoundsException;
213 int copy32(
final int srcLowBitnum,
final int dstLowBitnum,
final int length)
throws IndexOutOfBoundsException;
220 boolean get(
final int bitnum)
throws IndexOutOfBoundsException;
228 boolean put(
final int bitnum,
final boolean bit)
throws IndexOutOfBoundsException;
235 void set(
final int bitnum)
throws IndexOutOfBoundsException;
242 void clear(
final int bitnum)
throws IndexOutOfBoundsException;
251 boolean copy(
final int srcBitnum,
final int dstBitnum)
throws IndexOutOfBoundsException;
Simple Bitfield factory for returning the efficient implementation.
static Bitfield synchronize(final Bitfield impl)
Creates a synchronized Bitfield by wrapping the given Bitfield instance.
static Bitfield create(final int storageBitSize)
Creates am efficient Bitfield instance based on the requested storageBitSize.
Bit operation utilities (static).
static final int roundToPowerOf2(final int n)
If the given n is not isPowerOf2(int) return nextPowerOf2(int), otherwise return n unchanged.
static final int nextPowerOf2(int n)
Returns the next higher power of 2 of 32-bit of given n @endiliteral.
static final boolean isPowerOf2(final int n)
Returns true if the given integer is a power of 2.
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 inspire...
static final int MAX_POWER_OF_2
Maximum 32bit integer value being of isPowerOf2(int).
static int getBitMask(final int n)
Returns the 32 bit mask of n-bits, i.e.
Simple bitfield interface for efficient bit storage access in O(1).
void clear(final int bitnum)
Clear the bit at position bitnum according to bit.
int bitCount()
Returns the number of one bits within this bitfield.
void clearField(final boolean bit)
Set all bits of this bitfield to the given value bit.
int size()
Returns the storage size in bit units, e.g.
int get32(final int lowBitnum, final int length)
Returns length bits from this storage, starting with the lowest bit from the storage position lowBitn...
void put32(final int lowBitnum, final int length, final int data)
Puts length bits of given data into this storage, starting w/ the lowest bit to the storage position ...
static final int UNSIGNED_INT_MAX_VALUE
Maximum 32 bit Unsigned Integer Value: 0xffffffff == {@value}.
int copy32(final int srcLowBitnum, final int dstLowBitnum, final int length)
Copies length bits at position srcLowBitnum to position dstLowBitnum and returning the bits.
boolean put(final int bitnum, final boolean bit)
Set or clear the bit at position bitnum according to bit and return the previous value.
boolean copy(final int srcBitnum, final int dstBitnum)
Copies the bit at position srcBitnum to position dstBitnum and returning true if the bit is set,...