Package io.github.jbellis.jvector.util
Class AtomicFixedBitSet
java.lang.Object
io.github.jbellis.jvector.util.BitSet
io.github.jbellis.jvector.util.AtomicFixedBitSet
- All Implemented Interfaces:
Accountable
,Bits
A
BitSet
implementation that offers concurrent reads and writes through an AtomicLongArray
as bit storage.
For now, only implements the minimum functionality required by BitSet (in contrast to the extra methods in FixedBitSet).
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.github.jbellis.jvector.util.Bits
Bits.MatchAllBits, Bits.MatchNoBits
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Return an approximation of the cardinality of this set.int
Return the number of bits that are set.void
clear()
Clear all the bits of the set.void
clear
(int i) Clear the bit ati
.void
clear
(int startIndex, int endIndex) Clears a range of bits.boolean
get
(int i) Returns the value of the bit with the specifiedindex
.boolean
getAndSet
(int i) Set the bit ati
, returningtrue
if it was previously set.int
length()
The number of bits in the set.int
nextSetBit
(int index) Returns the index of the first set bit starting at the index specified.int
prevSetBit
(int index) Returns the index of the last set bit before or on the index specified.long
void
set
(int i) Set the bit ati
.
-
Constructor Details
-
AtomicFixedBitSet
public AtomicFixedBitSet(int numBits)
-
-
Method Details
-
length
-
set
-
get
public boolean get(int i) Description copied from interface:Bits
Returns the value of the bit with the specifiedindex
.- Parameters:
i
- index, should be non-negative. The result of passing negative or out of bounds values is undefined by this interface, just don't do it!- Returns:
true
if the bit is set,false
otherwise.
-
getAndSet
-
clear
-
clear
-
clear
-
cardinality
public int cardinality()Description copied from class:BitSet
Return the number of bits that are set. NOTE: this method is likely to run in linear time- Specified by:
cardinality
in classBitSet
-
approximateCardinality
public int approximateCardinality()Description copied from class:BitSet
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 returnsBitSet.cardinality()
.- Specified by:
approximateCardinality
in classBitSet
-
prevSetBit
public int prevSetBit(int index) Description copied from class:BitSet
Returns 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:
prevSetBit
in classBitSet
-
nextSetBit
public int nextSetBit(int index) Description copied from class:BitSet
Returns the index of the first set bit starting at the index specified.DocIdSetIterator.NO_MORE_DOCS
is returned if there are no more set bits.- Specified by:
nextSetBit
in classBitSet
-
ramBytesUsed
public long ramBytesUsed()
-