|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectchoco.mem.StoredBitSet
public class StoredBitSet
A set of bits (0/1 values) with backtrackable structures. Implemented with a backtrackable vector of integer.
Field Summary | |
---|---|
protected StoredIntVector |
representedBy
A stored integer vector containing the bit representation. |
Constructor Summary | |
---|---|
StoredBitSet(Environment env,
int initialSize)
Builds a new stored bit set. |
Method Summary | |
---|---|
int |
capacity()
|
int |
cardinality()
Number of bits on. |
void |
clear(int bitIndex)
Puts the specified bit off. |
void |
ensureCapacity(int bitIndex)
|
boolean |
get(int bitIndex)
|
IntIterator |
getCycleButIterator(int avoidIndex)
|
int |
nextSetBit(int fromIndex)
Returns the index of the first bit that is set to true
that occurs on or after the specified starting index. |
int |
prevSetBit(int fromIndex)
Returns the index of the first bit that is set to true
that occurs on or before the specified starting index. |
void |
set(int bitIndex)
Puts the specified bit on. |
void |
set(int index,
boolean value)
|
static int |
startingZeroCnt(int val)
Counts the number of clear bits starting from the heaviest (leftmost) one assumes val contains some bits that are set. |
static int |
trailingZeroCnt(int val)
Counts the number of clear bits starting from the lightest (rightmost) one assumes val contains some bits that are set. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final StoredIntVector representedBy
Constructor Detail |
---|
public StoredBitSet(Environment env, int initialSize)
env
- the environment reponsible of worlds managementinitialSize
- the initial size (number of bits needed)Method Detail |
---|
public int cardinality()
public void set(int bitIndex)
bitIndex
- the bit to put onpublic void clear(int bitIndex)
bitIndex
- the bit to put offpublic void set(int index, boolean value)
public boolean get(int bitIndex)
public int nextSetBit(int fromIndex)
true
that occurs on or after the specified starting index. If no such
bit exists then -1 is returned.
To iterate over the true
bits in a BitSet
,
use the following loop:
for(int i=bs.nextSetBit(0); i>=0; i=bs.nextSetBit(i+1)) {
// operate on index i here
}
fromIndex
- the index to start checking from (inclusive).
java.lang.IndexOutOfBoundsException
- if the specified index is negative.public static int trailingZeroCnt(int val)
val
- the integer, taken as a 32-bit set
public int prevSetBit(int fromIndex)
true
that occurs on or before the specified starting index. If no such
bit exists then -1 is returned.
fromIndex
- the index to start checking from (inclusive).
java.lang.IndexOutOfBoundsException
- if the specified index is
negative or too largepublic static int startingZeroCnt(int val)
val
- the integer, taken as a 32-bit set
public int capacity()
public void ensureCapacity(int bitIndex)
public IntIterator getCycleButIterator(int avoidIndex)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |