Package io.github.jbellis.jvector.util
Class BitSet
java.lang.Object
io.github.jbellis.jvector.util.BitSet
- All Implemented Interfaces:
Accountable,Bits
- Direct Known Subclasses:
AtomicFixedBitSet,FixedBitSet,GrowableBitSet,SparseFixedBitSet,SynchronizedGrowableBitSet
Base implementation for a bit set.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.github.jbellis.jvector.util.Bits
Bits.MatchAllBits, Bits.MatchNoBits -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract intReturn an approximation of the cardinality of this set.abstract intReturn the number of bits that are set.voidclear()Clear all the bits of the set.abstract voidclear(int i) Clear the bit ati.abstract voidclear(int startIndex, int endIndex) Clears a range of bits.abstract booleangetAndSet(int i) Set the bit ati, returningtrueif it was previously set.abstract intnextSetBit(int index) Returns the index of the first set bit starting at the index specified.abstract intprevSetBit(int index) Returns the index of the last set bit before or on the index specified.abstract voidset(int i) Set the bit ati.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.jbellis.jvector.util.Accountable
ramBytesUsed
-
Constructor Details
-
BitSet
public BitSet()
-
-
Method Details
-
clear
public void clear()Clear all the bits of the set.Depending on the implementation, this may be significantly faster than clear(0, length).
-
set
public abstract void set(int i) Set the bit ati. -
getAndSet
public abstract boolean getAndSet(int i) Set the bit ati, returningtrueif it was previously set. -
clear
public abstract void clear(int i) Clear the bit ati. -
clear
public abstract void clear(int startIndex, int endIndex) Clears a range of bits.- Parameters:
startIndex- lower indexendIndex- one-past the last bit to clear
-
cardinality
public abstract int cardinality()Return the number of bits that are set. NOTE: this method is likely to run in linear time -
approximateCardinality
public abstract int approximateCardinality()Return an approximation of the cardinality of this set. Some implementations may trade accuracy for speed if they have the ability to estimate the cardinality of the set without iterating over all the data. The default implementation returnscardinality(). -
prevSetBit
public abstract int prevSetBit(int index) Returns the index of the last set bit before or on the index specified. -1 is returned if there are no more set bits. -
nextSetBit
public abstract int nextSetBit(int index) Returns the index of the first set bit starting at the index specified.DocIdSetIterator.NO_MORE_DOCSis returned if there are no more set bits.
-