public final class

BitVector

extends Object
implements Cloneable
java.lang.Object
   ↳ org.apache.lucene.util.BitVector

Class Overview

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;
  • store and load, as bit set or d-gaps, depending on sparseness;

Summary

Public Constructors
BitVector(int n)
Constructs a vector capable of holding n bits.
BitVector(Directory d, String name)
Constructs a bit vector from the file name in Directory d, as written by the write(Directory, String) method.
Public Methods
final void clear(int bit)
Sets the value of bit to zero.
Object clone()
final int count()
Returns the total number of one bits in this vector.
final boolean get(int bit)
Returns true if bit is one and false if it is zero.
final boolean getAndSet(int bit)
Sets the value of bit to true, and returns true if bit was already set
final int getRecomputedCount()
For testing
final void set(int bit)
Sets the value of bit to one.
final int size()
Returns the number of bits in this vector.
BitVector subset(int start, int end)
Retrieve a subset of this BitVector.
final void write(Directory d, String name)
Writes this vector to the file name in Directory d, in a format that can be read by the constructor BitVector(Directory, String).
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public BitVector (int n)

Constructs a vector capable of holding n bits.

public BitVector (Directory d, String name)

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

Throws
IOException

Public Methods

public final void clear (int bit)

Sets the value of bit to zero.

public Object clone ()

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.

public final boolean get (int bit)

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

public final boolean getAndSet (int bit)

Sets the value of bit to true, and returns true if bit was already set

public final int getRecomputedCount ()

For testing

public final void set (int bit)

Sets the value of bit to one.

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.

public BitVector subset (int start, int end)

Retrieve a subset of this BitVector.

Parameters
start starting index, inclusive
end ending index, exclusive
Returns
  • subset

public final void write (Directory d, String name)

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

Throws
IOException