public class FastBitSet extends FastSet<Index>
A high-performance bitset with real-time behavior.
This class is integrated with the collection framework as
a set of indices and obeys the collection semantic
for methods such as FastSet.size() (cardinality) or FastCollection.equals(java.lang.Object)
(same set of indices).
FastCollection.Format| Modifier | Constructor and Description |
|---|---|
|
FastBitSet()
Creates an empty bit set.
|
protected |
FastBitSet(BitSetService impl)
Creates a fast bit set based on the specified implementation.
|
| Modifier and Type | Method and Description |
|---|---|
FastBitSet |
addAll(FastCollection<? extends Index> elements)
Returns this collection with the specified collection's elements added
in sequence.
|
FastBitSet |
addAll(Index... elements)
Returns this collection with the specified element added.
|
void |
and(FastBitSet that)
Performs the logical AND operation on this bit set and the
given bit set.
|
void |
andNot(FastBitSet that)
Performs the logical AND operation on this bit set and the
complement of the given bit set.
|
int |
cardinality()
Returns the number of bits set to
true (or the size of this
set). |
void |
clear()
Sets all bits in the set to
false (empty the set). |
void |
clear(int bitIndex)
Removes the specified integer value from this set.
|
void |
clear(int fromIndex,
int toIndex)
Sets the bits from the specified
fromIndex (inclusive) to the
specified toIndex (exclusive) to false. |
void |
flip(int bitIndex)
Sets the bit at the index to the opposite value.
|
void |
flip(int fromIndex,
int toIndex)
Sets a range of bits to the opposite value.
|
boolean |
get(int bitIndex)
Returns
true if the specified integer is in
this bit set; false otherwise. |
FastBitSet |
get(int fromIndex,
int toIndex)
Returns a new bit set composed of a range of bits from this one.
|
boolean |
intersects(FastBitSet that)
Returns
true if this bit set shares at least one
common bit with the specified bit set. |
int |
length()
Returns the logical number of bits actually used by this bit
set.
|
int |
nextClearBit(int fromIndex)
Returns the index of the next
false bit, from the specified bit
(inclusive). |
int |
nextSetBit(int fromIndex)
Returns the index of the next
true bit, from the specified bit
(inclusive). |
void |
or(FastBitSet that)
Performs the logical OR operation on this bit set and the one specified.
|
int |
previousClearBit(int fromIndex)
Returns the index of the previous
false bit,
from the specified bit (inclusive). |
int |
previousSetBit(int fromIndex)
Returns the index of the previous
true bit, from the
specified bit (inclusive). |
protected BitSetService |
service()
Returns the service implementation of this collection (for sub-classes).
|
void |
set(int bitIndex)
Adds the specified integer to this set (corresponding bit is set to
true. |
void |
set(int bitIndex,
boolean value)
Sets the bit at the given index to the specified value.
|
void |
set(int fromIndex,
int toIndex)
Sets the bits from the specified
fromIndex (inclusive) to the
specified toIndex (exclusive) to true. |
void |
set(int fromIndex,
int toIndex,
boolean value)
Sets the bits between from (inclusive) and to (exclusive) to the
specified value.
|
FastBitSet |
shared()
Returns a thread-safe view over this collection.
|
FastBitSet |
unmodifiable()
Returns an unmodifiable view over this collection.
|
void |
xor(FastBitSet that)
Performs the logical XOR operation on this bit set and the one specified.
|
atomic, contains, filtered, isEmpty, remove, sizeadd, addAll, any, comparator, containsAll, distinct, equals, forEach, hashCode, iterator, mapped, max, min, parallel, perform, reduce, removeAll, removeIf, retainAll, reversed, sequential, serviceOf, sorted, sorted, toArray, toArray, toImmutable, toString, updatepublic FastBitSet()
protected FastBitSet(BitSetService impl)
public FastBitSet unmodifiable()
FastCollectionUnsupportedOperationException being raised.unmodifiable in class FastSet<Index>public FastBitSet shared()
FastCollectionConcurrentModificationException possible).@Realtime(limit=LINEAR) public void and(FastBitSet that)
that - the second bit set.@Realtime(limit=LINEAR) public void andNot(FastBitSet that)
that - the second bit setpublic int cardinality()
true (or the size of this
set).public void clear()
false (empty the set).public void clear(int bitIndex)
bitIndex - a non-negative integer.IndexOutOfBoundsException - if index < 0@Realtime(limit=LINEAR) public void clear(int fromIndex, int toIndex)
fromIndex (inclusive) to the
specified toIndex (exclusive) to false.fromIndex - index of the first bit to be cleared.toIndex - index after the last bit to be cleared.IndexOutOfBoundsException - if
(fromIndex < 0) | (toIndex < fromIndex)public void flip(int bitIndex)
bitIndex - the index of the bit.IndexOutOfBoundsException - if bitIndex < 0@Realtime(limit=LINEAR) public void flip(int fromIndex, int toIndex)
fromIndex - the low index (inclusive).toIndex - the high index (exclusive).IndexOutOfBoundsException - if
(fromIndex < 0) | (toIndex < fromIndex)public boolean get(int bitIndex)
true if the specified integer is in
this bit set; false otherwise.bitIndex - a non-negative integer.IndexOutOfBoundsException - if bitIndex < 0@Realtime(limit=LINEAR) public FastBitSet get(int fromIndex, int toIndex)
fromIndex - the low index (inclusive).toIndex - the high index (exclusive).IndexOutOfBoundsException - if
(fromIndex < 0) | (toIndex < fromIndex)@Realtime(limit=LINEAR) public boolean intersects(FastBitSet that)
true if this bit set shares at least one
common bit with the specified bit set.that - the bit set to check for intersectiontrue if the sets intersect; false otherwise.public int length()
Note: This method does not return the number of set bits
which is returned by FastSet.size()
public int nextClearBit(int fromIndex)
false bit, from the specified bit
(inclusive).fromIndex - the start location.false bit.IndexOutOfBoundsException - if fromIndex < 0public int nextSetBit(int fromIndex)
true bit, from the specified bit
(inclusive). If there is none, -1 is returned.
The following code will iterates through the bit set:
for (int i=nextSetBit(0); i >= 0; i = nextSetBit(i+1)) {
...
}fromIndex - the start location.false bit.IndexOutOfBoundsException - if fromIndex < 0public int previousClearBit(int fromIndex)
false bit,
from the specified bit (inclusive).fromIndex - the start location.false bit.IndexOutOfBoundsException - if fromIndex < -1public int previousSetBit(int fromIndex)
true bit, from the
specified bit (inclusive). If there is none, -1 is returned.
The following code will iterates through the bit set:
for (int i = length(); (i = previousSetBit(i-1)) >= 0; ) {
...
}fromIndex - the start location.false bit.IndexOutOfBoundsException - if fromIndex < -1@Realtime(limit=LINEAR) public void or(FastBitSet that)
that - the second bit set.public void set(int bitIndex)
true.bitIndex - a non-negative integer.IndexOutOfBoundsException - if bitIndex < 0public void set(int bitIndex,
boolean value)
bitIndex - the position to set.value - the value to set it to.IndexOutOfBoundsException - if bitIndex < 0@Realtime(limit=LINEAR) public void set(int fromIndex, int toIndex)
fromIndex (inclusive) to the
specified toIndex (exclusive) to true.fromIndex - index of the first bit to be set.toIndex - index after the last bit to be set.IndexOutOfBoundsException - if
(fromIndex < 0) | (toIndex < fromIndex)@Realtime(limit=LINEAR) public void set(int fromIndex, int toIndex, boolean value)
fromIndex - the start range (inclusive).toIndex - the end range (exclusive).value - the value to set it to.IndexOutOfBoundsException - if bitIndex < 0@Realtime(limit=LINEAR) public void xor(FastBitSet that)
that - the second bit set.public FastBitSet addAll(Index... elements)
FastCollectionpublic FastBitSet addAll(FastCollection<? extends Index> elements)
FastCollectionprotected BitSetService service()
FastCollectionCopyright © 2005-2013 Javolution. All Rights Reserved.