Package org.apache.lucene.util
Class FixedBitSet
- java.lang.Object
-
- org.apache.lucene.search.DocIdSet
-
- org.apache.lucene.util.FixedBitSet
-
- All Implemented Interfaces:
Bits
public final class FixedBitSet extends DocIdSet implements Bits
BitSet of fixed length (numBits), backed by accessible (getBits()) long[], accessed with an int index, implementing Bits and DocIdSet. UnlikeOpenBitSetthis bit set does not auto-expand, cannot handle long index, and does not have fastXX/XX variants (just X).- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.lucene.util.Bits
Bits.MatchAllBits, Bits.MatchNoBits
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.search.DocIdSet
EMPTY_DOCIDSET
-
Fields inherited from interface org.apache.lucene.util.Bits
EMPTY_ARRAY
-
-
Constructor Summary
Constructors Constructor Description FixedBitSet(int numBits)FixedBitSet(FixedBitSet other)Makes full copy.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidand(DocIdSetIterator iter)Does in-place AND of the bits provided by the iterator.voidand(FixedBitSet other)this = this AND othervoidandNot(DocIdSetIterator iter)Does in-place AND NOT of the bits provided by the iterator.voidandNot(FixedBitSet other)this = this AND NOT otherstatic intbits2words(int numBits)returns the number of 64 bit words it would take to hold numBitsintcardinality()Returns number of set bits.voidclear(int index)voidclear(int startIndex, int endIndex)Clears a range of bits.Objectclone()booleanequals(Object o)returns true if both sets have the same bits setvoidflip(int startIndex, int endIndex)Flips a range of bitsbooleanget(int index)booleangetAndClear(int index)booleangetAndSet(int index)long[]getBits()Expert.inthashCode()booleanisCacheable()This DocIdSet implementation is cacheable.DocIdSetIteratoriterator()Provides aDocIdSetIteratorto access the set.intlength()intnextSetBit(int index)Returns the index of the first set bit starting at the index specified.voidor(DocIdSetIterator iter)Does in-place OR of the bits provided by the iterator.voidor(FixedBitSet other)this = this OR otherintprevSetBit(int index)Returns the index of the last set bit before or on the index specified.voidset(int index)voidset(int startIndex, int endIndex)Sets a range of bits
-
-
-
Constructor Detail
-
FixedBitSet
public FixedBitSet(int numBits)
-
FixedBitSet
public FixedBitSet(FixedBitSet other)
Makes full copy.
-
-
Method Detail
-
bits2words
public static int bits2words(int numBits)
returns the number of 64 bit words it would take to hold numBits
-
iterator
public DocIdSetIterator iterator()
Description copied from class:DocIdSetProvides aDocIdSetIteratorto access the set. This implementation can returnnullorDocIdSet.EMPTY_DOCIDSET.iterator()if there are no docs that match.
-
isCacheable
public boolean isCacheable()
This DocIdSet implementation is cacheable.- Overrides:
isCacheablein classDocIdSet
-
getBits
public long[] getBits()
Expert.
-
cardinality
public int cardinality()
Returns number of set bits. NOTE: this visits every long in the backing bits array, and the result is not internally cached!
-
set
public void set(int index)
-
getAndSet
public boolean getAndSet(int index)
-
clear
public void clear(int index)
-
getAndClear
public boolean getAndClear(int index)
-
nextSetBit
public int nextSetBit(int index)
Returns the index of the first set bit starting at the index specified. -1 is returned if there are no more set bits.
-
prevSetBit
public 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.
-
or
public void or(DocIdSetIterator iter) throws IOException
Does in-place OR of the bits provided by the iterator.- Throws:
IOException
-
or
public void or(FixedBitSet other)
this = this OR other
-
and
public void and(DocIdSetIterator iter) throws IOException
Does in-place AND of the bits provided by the iterator.- Throws:
IOException
-
and
public void and(FixedBitSet other)
this = this AND other
-
andNot
public void andNot(DocIdSetIterator iter) throws IOException
Does in-place AND NOT of the bits provided by the iterator.- Throws:
IOException
-
andNot
public void andNot(FixedBitSet other)
this = this AND NOT other
-
flip
public void flip(int startIndex, int endIndex)Flips a range of bits- Parameters:
startIndex- lower indexendIndex- one-past the last bit to flip
-
set
public void set(int startIndex, int endIndex)Sets a range of bits- Parameters:
startIndex- lower indexendIndex- one-past the last bit to set
-
clear
public void clear(int startIndex, int endIndex)Clears a range of bits.- Parameters:
startIndex- lower indexendIndex- one-past the last bit to clear
-
equals
public boolean equals(Object o)
returns true if both sets have the same bits set
-
-