Package io.github.jbellis.jvector.util
Class SynchronizedGrowableBitSet
java.lang.Object
io.github.jbellis.jvector.util.BitSet
io.github.jbellis.jvector.util.SynchronizedGrowableBitSet
- All Implemented Interfaces:
Accountable,Bits
A thread-safe
BitSet implementation that grows as needed to accommodate set(index) calls. When it
does so, it will grow its internal storage multiplicatively, assuming that more growth will be
needed in the future. This is the important difference from FixedBitSet + FBS.ensureCapacity,
which grows the minimum necessary each time.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.github.jbellis.jvector.util.Bits
Bits.MatchAllBits, Bits.MatchNoBits -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionSynchronizedGrowableBitSet(int initialBits) SynchronizedGrowableBitSet(BitSet bitSet) -
Method Summary
Modifier and TypeMethodDescriptionintReturn an approximation of the cardinality of this set.intReturn the number of bits that are set.voidclear()Clear all the bits of the set.voidclear(int index) Clear the bit ati.voidclear(int startIndex, int endIndex) Clears a range of bits.booleanget(int index) Returns the value of the bit with the specifiedindex.booleangetAndSet(int index) Set the bit ati, returningtrueif it was previously set.intlength()Returns the number of bits in this setintnextSetBit(int i) Returns the index of the first set bit starting at the index specified.intprevSetBit(int index) Returns the index of the last set bit before or on the index specified.longvoidset(int i) Set the bit ati.
-
Constructor Details
-
SynchronizedGrowableBitSet
-
SynchronizedGrowableBitSet
public SynchronizedGrowableBitSet(int initialBits)
-
-
Method Details
-
clear
public void clear(int index) Description copied from class:BitSetClear the bit ati. -
clear
public void clear()Description copied from class:BitSetClear all the bits of the set.Depending on the implementation, this may be significantly faster than clear(0, length).
-
get
public boolean get(int index) Description copied from interface:BitsReturns the value of the bit with the specifiedindex.- Parameters:
index- index, should be non-negative and <Bits.length(). The result of passing negative or out of bounds values is undefined by this interface, just don't do it!- Returns:
trueif the bit is set,falseotherwise.
-
getAndSet
public boolean getAndSet(int index) Description copied from class:BitSetSet the bit ati, returningtrueif it was previously set. -
length
public int length()Description copied from interface:BitsReturns the number of bits in this set -
set
public void set(int i) Description copied from class:BitSetSet the bit ati. -
clear
public void clear(int startIndex, int endIndex) Description copied from class:BitSetClears a range of bits. -
cardinality
public int cardinality()Description copied from class:BitSetReturn the number of bits that are set. NOTE: this method is likely to run in linear time- Specified by:
cardinalityin classBitSet
-
approximateCardinality
public int approximateCardinality()Description copied from class:BitSetReturn 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 returnsBitSet.cardinality().- Specified by:
approximateCardinalityin classBitSet
-
prevSetBit
public int prevSetBit(int index) Description copied from class:BitSetReturns the index of the last set bit before or on the index specified. -1 is returned if there are no more set bits.- Specified by:
prevSetBitin classBitSet
-
nextSetBit
public int nextSetBit(int i) Description copied from class:BitSetReturns the index of the first set bit starting at the index specified.DocIdSetIterator.NO_MORE_DOCSis returned if there are no more set bits.- Specified by:
nextSetBitin classBitSet
-
ramBytesUsed
public long ramBytesUsed()
-