public interface IStateBitSet
Modifier and Type | Method and Description |
---|---|
int |
cardinality()
Number of bits on.
|
void |
clear()
Remove all bits;
|
void |
clear(int bitIndex)
Puts the specified bit off.
|
void |
clear(int fromIndex,
int toIndex) |
boolean |
get(int bitIndex) |
boolean |
isEmpty() |
int |
nextClearBit(int fromIndex)
Returns the index of the first bit that is set to
false
that occurs on or after the specified starting index. |
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 |
prevClearBit(int fromIndex)
Returns the index of the first bit that is set to
false
that occurs on or before 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) |
void |
set(int fromIdex,
int toIndex) |
int |
size()
Size of the bitset
|
int cardinality()
int size()
void set(int bitIndex)
bitIndex
- the bit to put onvoid clear(int bitIndex)
bitIndex
- the bit to put offvoid clear()
void clear(int fromIndex, int toIndex)
void set(int index, boolean value)
void set(int fromIdex, int toIndex)
boolean get(int bitIndex)
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).IndexOutOfBoundsException
- if the specified index is negative.int nextClearBit(int fromIndex)
false
that occurs on or after the specified starting index.fromIndex
- the index to start checking from (inclusive).IndexOutOfBoundsException
- if the specified index is negative.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).IndexOutOfBoundsException
- if the specified index is
negative or too largeint prevClearBit(int fromIndex)
false
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).IndexOutOfBoundsException
- if the specified index is
negative or too largeboolean isEmpty()
Copyright © 2018. All rights reserved.