Lucene++ - a full-featured, c++ search engine
API Documentation


Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
Lucene::BitVector Class Reference

Optimized implementation of a vector of bits. More...

#include <BitVector.h>

+ Inheritance diagram for Lucene::BitVector:

Public Member Functions

 BitVector (int32_t n=0)
 Constructs a vector capable of holding n bits.
 
 BitVector (ByteArray bits, int32_t size)
 
 BitVector (const DirectoryPtr &d, const String &name)
 Constructs a bit vector from the file name in Directory d, as written by the write method.
 
virtual ~BitVector ()
 
virtual String getClassName ()
 
boost::shared_ptr< BitVectorshared_from_this ()
 
virtual LuceneObjectPtr clone (const LuceneObjectPtr &other=LuceneObjectPtr())
 Clone this vector.
 
void set (int32_t bit)
 Sets the value of bit to one.
 
bool getAndSet (int32_t bit)
 Sets the value of bit to true, and returns true if bit was already set.
 
void clear (int32_t bit)
 Sets the value of bit to zero.
 
bool get (int32_t bit)
 Returns true if bit is one and false if it is zero.
 
int32_t size ()
 Returns the number of bits in this vector. This is also one greater than the number of the largest valid bit number.
 
int32_t 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.
 
int32_t getRecomputedCount ()
 For testing.
 
void write (const DirectoryPtr &d, const String &name)
 Writes this vector to the file name in Directory d, in a format that can be read by the constructor BitVector(DirectoryPtr, const String&).
 
BitVectorPtr subset (int32_t start, int32_t end)
 Retrieve a subset of this BitVector.
 
- Public Member Functions inherited from Lucene::LuceneObject
virtual ~LuceneObject ()
 
virtual void initialize ()
 Called directly after instantiation to create objects that depend on this object being fully constructed.
 
virtual int32_t hashCode ()
 Return hash code for this object.
 
virtual bool equals (const LuceneObjectPtr &other)
 Return whether two objects are equal.
 
virtual int32_t compareTo (const LuceneObjectPtr &other)
 Compare two objects.
 
virtual String toString ()
 Returns a string representation of the object.
 
- Public Member Functions inherited from Lucene::LuceneSync
virtual ~LuceneSync ()
 
virtual SynchronizePtr getSync ()
 Return this object synchronize lock.
 
virtual LuceneSignalPtr getSignal ()
 Return this object signal.
 
virtual void lock (int32_t timeout=0)
 Lock this object using an optional timeout.
 
virtual void unlock ()
 Unlock this object.
 
virtual bool holdsLock ()
 Returns true if this object is currently locked by current thread.
 
virtual void wait (int32_t timeout=0)
 Wait for signal using an optional timeout.
 
virtual void notifyAll ()
 Notify all threads waiting for signal.
 

Static Public Member Functions

static String _getClassName ()
 

Protected Member Functions

void writeBits (const IndexOutputPtr &output)
 Write as a bit set.
 
void writeDgaps (const IndexOutputPtr &output)
 Write as a d-gaps list.
 
bool isSparse ()
 Indicates if the bit vector is sparse and should be saved as a d-gaps list, or dense, and should be saved as a bit set.
 
void readBits (const IndexInputPtr &input)
 Read as a bit set.
 
void readDgaps (const IndexInputPtr &input)
 Read as a d-gaps list.
 
- Protected Member Functions inherited from Lucene::LuceneObject
 LuceneObject ()
 

Protected Attributes

ByteArray bits
 
int32_t _size
 
int32_t _count
 
- Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr objectLock
 
LuceneSignalPtr objectSignal
 

Static Protected Attributes

static const uint8_t BYTE_COUNTS []
 

Detailed Description

Optimized implementation of a vector of bits.

Constructor & Destructor Documentation

◆ BitVector() [1/3]

Lucene::BitVector::BitVector ( int32_t  n = 0)

Constructs a vector capable of holding n bits.

◆ BitVector() [2/3]

Lucene::BitVector::BitVector ( ByteArray  bits,
int32_t  size 
)

◆ BitVector() [3/3]

Lucene::BitVector::BitVector ( const DirectoryPtr d,
const String &  name 
)

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

◆ ~BitVector()

virtual Lucene::BitVector::~BitVector ( )
virtual

Member Function Documentation

◆ _getClassName()

static String Lucene::BitVector::_getClassName ( )
inlinestatic

◆ clear()

void Lucene::BitVector::clear ( int32_t  bit)

Sets the value of bit to zero.

◆ clone()

virtual LuceneObjectPtr Lucene::BitVector::clone ( const LuceneObjectPtr other = LuceneObjectPtr())
virtual

Clone this vector.

Reimplemented from Lucene::LuceneObject.

◆ count()

int32_t Lucene::BitVector::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()

bool Lucene::BitVector::get ( int32_t  bit)

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

◆ getAndSet()

bool Lucene::BitVector::getAndSet ( int32_t  bit)

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

◆ getClassName()

virtual String Lucene::BitVector::getClassName ( )
inlinevirtual

◆ getRecomputedCount()

int32_t Lucene::BitVector::getRecomputedCount ( )

For testing.

◆ isSparse()

bool Lucene::BitVector::isSparse ( )
protected

Indicates if the bit vector is sparse and should be saved as a d-gaps list, or dense, and should be saved as a bit set.

◆ readBits()

void Lucene::BitVector::readBits ( const IndexInputPtr input)
protected

Read as a bit set.

◆ readDgaps()

void Lucene::BitVector::readDgaps ( const IndexInputPtr input)
protected

Read as a d-gaps list.

◆ set()

void Lucene::BitVector::set ( int32_t  bit)

Sets the value of bit to one.

◆ shared_from_this()

boost::shared_ptr< BitVector > Lucene::BitVector::shared_from_this ( )
inline

◆ size()

int32_t Lucene::BitVector::size ( )

Returns the number of bits in this vector. This is also one greater than the number of the largest valid bit number.

◆ subset()

BitVectorPtr Lucene::BitVector::subset ( int32_t  start,
int32_t  end 
)

Retrieve a subset of this BitVector.

Parameters
startstarting index, inclusive
endending index, exclusive
Returns
subset

◆ write()

void Lucene::BitVector::write ( const DirectoryPtr d,
const String &  name 
)

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

◆ writeBits()

void Lucene::BitVector::writeBits ( const IndexOutputPtr output)
protected

Write as a bit set.

◆ writeDgaps()

void Lucene::BitVector::writeDgaps ( const IndexOutputPtr output)
protected

Write as a d-gaps list.

Field Documentation

◆ _count

int32_t Lucene::BitVector::_count
protected

◆ _size

int32_t Lucene::BitVector::_size
protected

◆ bits

ByteArray Lucene::BitVector::bits
protected

◆ BYTE_COUNTS

const uint8_t Lucene::BitVector::BYTE_COUNTS[]
staticprotected

The documentation for this class was generated from the following file:

clucene.sourceforge.net