public class SparseBitSet extends java.lang.Object implements LongSortedSet
log(n) performance for accessing
individual bits. Memory usage is roughly proportional to bitCount(). The bit set can set any bit between
0 and Long.MAX_VALUE, inclusive. However, the maximum number of 64-bit words in use is limited by
the int length limit of arrays.| Constructor and Description |
|---|
SparseBitSet()
Construct a
SparseBitSet. |
SparseBitSet(int capacity)
Construct a
SparseBitSet with the given initial capacity. |
SparseBitSet(long... values)
Construct a
SparseBitSet with the given values. |
| Modifier and Type | Method and Description |
|---|---|
long |
bitCount() |
void |
clear()
Reset this
SparseBitSet to the empty state, i.e. with no bits set. |
boolean |
clear(long i)
Clear the bit at index
i. |
LongIterator |
descendingIterator() |
boolean |
equals(java.lang.Object o) |
long |
firstLong() |
boolean |
get(long i)
Get the bit at index
i. |
int |
hashCode() |
boolean |
isEmpty() |
LongIterator |
iterator() |
long |
lastLong() |
boolean |
set(long i)
Set the bit at index
i. |
boolean |
set(long i,
boolean value)
Set the bit at index
i to the given value. |
int |
size() |
java.lang.String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcomparator, first, headSet, headSet, last, spliterator, subSet, subSet, tailSet, tailSetadd, addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArrayaddAllLongs, addAllLongs, addLong, removeIf, toLongArraycontainsAllLongs, containsAllLongs, containsAnyLongs, containsAnyLongs, containsLong, forEach, forEachLong, from, from, longStream, of, once, once, parallelLongStream, removeAllLongs, removeAllLongs, removeLong, removeLongsIf, retainAllLongs, retainAllLongs, sequencepublic SparseBitSet()
SparseBitSet.public SparseBitSet(long... values)
SparseBitSet with the given values.public SparseBitSet(int capacity)
SparseBitSet with the given initial capacity.public boolean set(long i)
i.true if this bit set changed as a result of setting the bit, i.e. the bit was clear,
false otherwise.public boolean clear(long i)
i.true if this bit set changed as a result of setting the bit, i.e. the bit was set,
false otherwise.public boolean set(long i,
boolean value)
i to the given value.true if this bit set changed as a result of changing the bit, false otherwise.public boolean get(long i)
i.true if the bit at index i is set, false otherwise.public long bitCount()
SparseBitSet.public int size()
size in interface java.util.Collection<java.lang.Long>size in interface java.util.Set<java.lang.Long>SparseBitSet, i.e. the number of set bits.bitCount()public boolean isEmpty()
isEmpty in interface java.util.Collection<java.lang.Long>isEmpty in interface java.util.Set<java.lang.Long>isEmpty in interface LongCollectionisEmpty in interface LongIterableisEmpty in interface LongSetSparseBitSet contains no set bits, false otherwise.public void clear()
SparseBitSet to the empty state, i.e. with no bits set.clear in interface java.util.Collection<java.lang.Long>clear in interface java.util.Set<java.lang.Long>clear in interface LongCollectionclear in interface LongIterableclear in interface LongSetpublic long firstLong()
firstLong in interface LongSortedSetpublic long lastLong()
lastLong in interface LongSortedSetpublic LongIterator iterator()
iterator in interface java.lang.Iterable<java.lang.Long>iterator in interface java.util.Collection<java.lang.Long>iterator in interface java.util.Set<java.lang.Long>iterator in interface LongIterableLongIterator over the bits in this SparseBitSet, from lowest to highest.
All LongIterator methods are constant time. Iterator.remove() is supported.public LongIterator descendingIterator()
LongIterator over the bits in this SparseBitSet, from highest to lowest.
All LongIterator methods are constant time. Iterator.remove() is supported.public java.lang.String toString()
toString in class java.lang.ObjectBitSet in the same format as BitSet.toString(), e.g.
the indices of all the set bits in ascending order surrounded by curly brackets "{}".public boolean equals(java.lang.Object o)
equals in interface java.util.Collection<java.lang.Long>equals in interface java.util.Set<java.lang.Long>equals in class java.lang.Objectpublic int hashCode()
hashCode in interface java.util.Collection<java.lang.Long>hashCode in interface java.util.Set<java.lang.Long>hashCode in class java.lang.Object