public class SparseBitSet extends LongSet.Base 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 sparse 64-bit words in use by the
set bits in the bit set is limited by the int length limit of arrays.LongSortedSet.SubSetLongSet.Base| 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 |
|---|---|
boolean |
addLong(long x) |
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. |
boolean |
containsLong(long x) |
LongIterator |
descendingIterator() |
long |
firstLong() |
boolean |
get(long i)
Get the bit at index
i. |
boolean |
isEmpty() |
LongIterator |
iterator() |
long |
lastLong() |
boolean |
removeLong(long x) |
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() |
equals, hashCodeclone, finalize, getClass, notify, notifyAll, wait, wait, waitcomparator, create, create, first, headSet, headSet, last, spliterator, subSet, subSet, tailSet, tailSetadd, addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArrayaddAllLongs, addAllLongs, removeIf, toLongArraycontainsAllLongs, containsAllLongs, containsAnyLongs, containsAnyLongs, forEach, forEachLong, from, from, longStream, of, once, once, parallelLongStream, removeAllLongs, removeAllLongs, 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 addLong(long x)
addLong in interface LongCollectionpublic boolean containsLong(long x)
containsLong in interface LongIterablepublic boolean removeLong(long x)
removeLong in interface LongIterablepublic 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 LongCollection.BaseBitSet in the same format as BitSet.toString(), e.g.
the indices of all the set bits in ascending order surrounded by curly brackets "{}".