org.apache.lucene.util
Class BitVector
- java.lang.Object
-
- org.apache.lucene.util.BitVector
-
public final class BitVector extends java.lang.ObjectOptimized implementation of a vector of bits. This is more-or-less like java.util.BitSet, but also includes the following:- a count() method, which efficiently computes the number of one bits;
- optimized read from and write to disk;
- inlinable get() method;
- store and load, as bit set or d-gaps, depending on sparseness;
-
-
Constructor Summary
Constructors Constructor and Description BitVector(Directory d, java.lang.String name)Constructs a bit vector from the filenamein Directoryd, as written by thewrite(org.apache.lucene.store.Directory, java.lang.String)method.BitVector(int n)Constructs a vector capable of holdingnbits.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclear(int bit)Sets the value ofbitto zero.intcount()Returns the total number of one bits in this vector.booleanget(int bit)Returnstrueifbitis one andfalseif it is zero.voidset(int bit)Sets the value ofbitto one.intsize()Returns the number of bits in this vector.voidwrite(Directory d, java.lang.String name)Writes this vector to the filenamein Directoryd, in a format that can be read by the constructorBitVector(Directory, String).
-
-
-
Constructor Detail
-
BitVector
public BitVector(int n)
Constructs a vector capable of holdingnbits.
-
BitVector
public BitVector(Directory d, java.lang.String name) throws java.io.IOException
Constructs a bit vector from the filenamein Directoryd, as written by thewrite(org.apache.lucene.store.Directory, java.lang.String)method.- Throws:
java.io.IOException
-
-
Method Detail
-
set
public final void set(int bit)
Sets the value ofbitto one.
-
clear
public final void clear(int bit)
Sets the value ofbitto zero.
-
get
public final boolean get(int bit)
Returnstrueifbitis one andfalseif it is zero.
-
size
public final int size()
Returns the number of bits in this vector. This is also one greater than the number of the largest valid bit number.
-
count
public final int count()
Returns the total number of one bits in this vector. This is efficiently computed and cached, so that, if the vector is not changed, no recomputation is done for repeated calls.
-
write
public final void write(Directory d, java.lang.String name) throws java.io.IOException
Writes this vector to the filenamein Directoryd, in a format that can be read by the constructorBitVector(Directory, String).- Throws:
java.io.IOException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG