Documentation  › org.apache.lucene.util  › BitVector
 
 


  BitVector
  public final

  Inherits From:   Object
  Conforms To:   none
  Declared In:   org.apache.lucene.util


Class Description
 
Optimized 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;


Class Variables
 
None declared in this class.


Instance Variables
 
None declared in this class.


Constructors
 
BitVector
public BitVector( Directory d, String name ) throws IOException

Constructs a bit vector from the file name in Directory d, as written by the write method.


BitVector
public BitVector( int n )

Constructs a vector capable of holding n bits.


Class Methods
 
None declared in this class.


Instance Methods
 
clear
public final void clear( int bit )

Sets the value of bit to zero.


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.


get
public final boolean get( int bit )

Returns true if bit is one and false if it is zero.


set
public final void set( int bit )

Sets the value of bit to one.


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.


write
public final void write( Directory d, String name ) throws IOException

Writes this vector to the file name in Directory d, in a format that can be read by the constructor BitVector(Directory,String).


Known Subclasses
 
None.



 
 
  dydoc
  3/9/05