org.apache.lucene.util

Class BitVector

public final class BitVector extends Object

Optimized implementation of a vector of bits. This is more-or-less like java.util.BitSet, but also includes the following:

Version: $Id: BitVector.java 150536 2004-09-28 18:15:52Z cutting $

Author: Doug Cutting

Constructor Summary
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 {@link #write} method.
Method Summary
voidclear(int bit)
Sets the value of bit to zero.
intcount()
Returns the total number of one bits in this vector.
booleanget(int bit)
Returns true if bit is one and false if it is zero.
voidset(int bit)
Sets the value of bit to one.
intsize()
Returns the number of bits in this vector.
voidwrite(Directory d, String name)
Writes this vector to the file name in Directory d, in a format that can be read by the constructor {@link #BitVector(Directory, String)}.

Constructor Detail

BitVector

public BitVector(int n)
Constructs a vector capable of holding n bits.

BitVector

public BitVector(Directory d, String name)
Constructs a bit vector from the file name in Directory d, as written by the {@link #write} method.

Method Detail

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)
Writes this vector to the file name in Directory d, in a format that can be read by the constructor {@link #BitVector(Directory, String)}.
Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.