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

Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
Lucene::OpenBitSet Class Reference

An "open" BitSet implementation that allows direct access to the array of words storing the bits. More...

`#include <OpenBitSet.h>`

Inheritance diagram for Lucene::OpenBitSet:

## Public Member Functions

| OpenBitSet (int64_t numBits=64)
| Constructs an OpenBitSet large enough to hold numBits. More...
| OpenBitSet (LongArray bits, int32_t numWords)
| Constructs an OpenBitSet from an existing LongArray. More...
virtual | ~OpenBitSet ()
virtual String | getClassName ()
boost::shared_ptr< OpenBitSet > | shared_from_this ()
virtual DocIdSetIteratorPtr | iterator ()
| Provides a DocIdSetIterator to access the set. This implementation can return null or EmptyDocIdSet.iterator() if there are no docs that match. More...
virtual bool | isCacheable ()
| This DocIdSet implementation is cacheable. More...
int64_t | capacity ()
| Returns the current capacity in bits (1 greater than the index of the last bit) More...
int64_t | size ()
| Returns the current capacity of this set. Included for compatibility. This is not equal to cardinality. More...
bool | isEmpty ()
| Returns true if there are no set bits. More...
LongArray | getBits ()
| Returns the long[] storing the bits. More...
void | setBits (LongArray bits)
| Sets a new long[] to use as the bit storage. More...
int32_t | getNumWords ()
| Gets the number of longs in the array that are in use. More...
void | setNumWords (int32_t numWords)
| Sets the number of longs in the array that are in use. More...
bool | get (int32_t index)
| Returns true or false for the specified bit index. More...
bool | fastGet (int32_t index)
| Returns true or false for the specified bit index. The index should be less than the OpenBitSet size. More...
bool | get (int64_t index)
| Returns true or false for the specified bit index. More...
bool | fastGet (int64_t index)
| Returns true or false for the specified bit index. The index should be less than the OpenBitSet size. More...
int32_t | getBit (int32_t index)
| Returns 1 if the bit is set, 0 if not. The index should be less than the OpenBitSet size. More...
void | set (int64_t index)
| Sets a bit, expanding the set size if necessary. More...
void | fastSet (int32_t index)
| Sets the bit at the specified index. The index should be less than the OpenBitSet size. More...
void | fastSet (int64_t index)
| Sets the bit at the specified index. The index should be less than the OpenBitSet size. More...
void | set (int64_t startIndex, int64_t endIndex)
| Sets a range of bits, expanding the set size if necessary. More...
void | fastClear (int32_t index)
| Clears a bit. The index should be less than the OpenBitSet size. More...
void | fastClear (int64_t index)
| Clears a bit. The index should be less than the OpenBitSet size. More...
void | clear (int64_t index)
| Clears a bit, allowing access beyond the current set size without changing the size. More...
void | clear (int32_t startIndex, int32_t endIndex)
| Clears a range of bits. Clearing past the end does not change the size of the set. More...
void | clear (int64_t startIndex, int64_t endIndex)
| Clears a range of bits. Clearing past the end does not change the size of the set. More...
bool | getAndSet (int32_t index)
| Sets a bit and returns the previous value. The index should be less than the OpenBitSet size. More...
bool | getAndSet (int64_t index)
| Sets a bit and returns the previous value. The index should be less than the OpenBitSet size. More...
void | fastFlip (int32_t index)
| Flips a bit. The index should be less than the OpenBitSet size. More...
void | fastFlip (int64_t index)
| Flips a bit. The index should be less than the OpenBitSet size. More...
void | flip (int64_t index)
| Flips a bit, expanding the set size if necessary. More...
bool | flipAndGet (int32_t index)
| Flips a bit and returns the resulting bit value. The index should be less than the OpenBitSet size. More...
bool | flipAndGet (int64_t index)
| Flips a bit and returns the resulting bit value. The index should be less than the OpenBitSet size. More...
void | flip (int64_t startIndex, int64_t endIndex)
| Flips a range of bits, expanding the set size if necessary. More...
int64_t | cardinality ()
int32_t | nextSetBit (int32_t index)
| Returns the index of the first set bit starting at the index specified. -1 is returned if there are no more set bits. More...
int64_t | nextSetBit (int64_t index)
| Returns the index of the first set bit starting at the index specified. -1 is returned if there are no more set bits. More...
virtual LuceneObjectPtr | clone (const LuceneObjectPtr &other=LuceneObjectPtr())
| Return clone of this object. More...
void | intersect (const OpenBitSetPtr &other)
| this = this AND other More...
void | _union (const OpenBitSetPtr &other)
| this = this OR other More...
void | remove (const OpenBitSetPtr &other)
| Remove all elements set in other. this = this AND_NOT other. More...
void | _xor (const OpenBitSetPtr &other)
| this = this XOR other More...
void | _and (const OpenBitSetPtr &other)
| see intersect More...
void | _or (const OpenBitSetPtr &other)
| see union More...
void | andNot (const OpenBitSetPtr &other)
| see remove More...
bool | intersects (const OpenBitSetPtr &other)
| Returns true if the sets have any elements in common. More...
void | ensureCapacityWords (int32_t numWords)
| Expand the LongArray with the size given as a number of words (64 bit longs). getNumWords() is unchanged by this call. More...
void | ensureCapacity (int64_t numBits)
| Ensure that the LongArray is big enough to hold numBits, expanding it if necessary. getNumWords() is unchanged by this call. More...
void | trimTrailingZeros ()
| Lowers numWords, the number of words in use, by checking for trailing zero words. More...
virtual bool | equals (const LuceneObjectPtr &other)
| Returns true if both sets have the same bits set. More...
virtual int32_t | hashCode ()
| Return hash code for this object. More...
Public Member Functions inherited from Lucene::DocIdSet
virtual | ~DocIdSet ()
boost::shared_ptr< DocIdSet > | shared_from_this ()
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. More...
virtual int32_t | compareTo (const LuceneObjectPtr &other)
| Compare two objects. More...
virtual String | toString ()
| Returns a string representation of the object. More...
Public Member Functions inherited from Lucene::LuceneSync
virtual | ~LuceneSync ()
virtual SynchronizePtr | getSync ()
| Return this object synchronize lock. More...
virtual LuceneSignalPtr | getSignal ()
| Return this object signal. More...
virtual void | lock (int32_t timeout=0)
| Lock this object using an optional timeout. More...
virtual void | unlock ()
| Unlock this object. More...
virtual bool | holdsLock ()
| Returns true if this object is currently locked by current thread. More...
virtual void | wait (int32_t timeout=0)
| Wait for signal using an optional timeout. More...
virtual void | notifyAll ()
| Notify all threads waiting for signal. More...

## Static Public Member Functions

static String | _getClassName ()
static int64_t | intersectionCount (const OpenBitSetPtr &a, const OpenBitSetPtr &b)
| Returns the popcount or cardinality of the intersection of the two sets. Neither set is modified. More...
static int64_t | unionCount (const OpenBitSetPtr &a, const OpenBitSetPtr &b)
| Returns the popcount or cardinality of the union of the two sets. Neither set is modified. More...
static int64_t | andNotCount (const OpenBitSetPtr &a, const OpenBitSetPtr &b)
| Returns the popcount or cardinality of "a and not b" or "intersection(a, not(b))". Neither set is modified. More...
static int64_t | xorCount (const OpenBitSetPtr &a, const OpenBitSetPtr &b)
| Returns the popcount or cardinality of the exclusive-or of the two sets. Neither set is modified. More...
static int32_t | bits2words (int64_t numBits)
| Returns the number of 64 bit words it would take to hold numBits. More...
Static Public Member Functions inherited from Lucene::DocIdSet
static String | _getClassName ()
static DocIdSetPtr | EMPTY_DOCIDSET ()
| An empty {. More...

## Protected Member Functions

int32_t | expandingWordNum (int64_t index)
Protected Member Functions inherited from Lucene::LuceneObject
| LuceneObject ()

## Protected Attributes

LongArray | bits
int32_t | wlen
Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr | objectLock
LuceneSignalPtr | objectSignal

## Detailed Description

An "open" BitSet implementation that allows direct access to the array of words storing the bits.

The goals of OpenBitSet are the fastest implementation possible, and maximum code reuse. Extra safety and encapsulation may always be built on top, but if that's built in, the cost can never be removed (and hence people re-implement their own version in order to get better performance).

## Constructor & Destructor Documentation

## ◆ OpenBitSet() [1/2]

Lucene::OpenBitSet::OpenBitSet | ( | int64_t | numBits = `64` | ) |

Constructs an OpenBitSet large enough to hold numBits.

## ◆ OpenBitSet() [2/2]

Lucene::OpenBitSet::OpenBitSet | ( | LongArray | bits,
|  | int32_t | numWords
| ) |  |

Constructs an OpenBitSet from an existing LongArray.

The first 64 bits are in long[0], with bit index 0 at the least significant bit, and bit index 63 at the most significant. Given a bit index, the word containing it is long[index/64], and it is at bit number index%64 within that word.

numWords are the number of elements in the array that contain set bits (non-zero longs). numWords should be <= bits.length(), and any existing words in the array at position >= numWords should be zero.

## ◆ ~OpenBitSet()

virtual Lucene::OpenBitSet::~OpenBitSet | ( |  | ) |

virtual

## Member Function Documentation

## ◆ _and()

void Lucene::OpenBitSet::_and | ( | const OpenBitSetPtr & | other | ) |

see intersect

## ◆ _getClassName()

static String Lucene::OpenBitSet::_getClassName | ( |  | ) |

inline static

## ◆ _or()

void Lucene::OpenBitSet::_or | ( | const OpenBitSetPtr & | other | ) |

see union

## ◆ _union()

void Lucene::OpenBitSet::_union | ( | const OpenBitSetPtr & | other | ) |

this = this OR other

## ◆ _xor()

void Lucene::OpenBitSet::_xor | ( | const OpenBitSetPtr & | other | ) |

this = this XOR other

## ◆ andNot()

void Lucene::OpenBitSet::andNot | ( | const OpenBitSetPtr & | other | ) |

see remove

## ◆ andNotCount()

static int64_t Lucene::OpenBitSet::andNotCount | ( | const OpenBitSetPtr & | a,
|  | const OpenBitSetPtr & | b
| ) |  |

static

Returns the popcount or cardinality of "a and not b" or "intersection(a, not(b))". Neither set is modified.

## ◆ bits2words()

static int32_t Lucene::OpenBitSet::bits2words | ( | int64_t | numBits | ) |

static

Returns the number of 64 bit words it would take to hold numBits.

## ◆ capacity()

int64_t Lucene::OpenBitSet::capacity | ( |  | ) |

Returns the current capacity in bits (1 greater than the index of the last bit)

## ◆ cardinality()

int64_t Lucene::OpenBitSet::cardinality | ( |  | ) |

Returns
  the number of set bits

## ◆ clear() [1/3]

void Lucene::OpenBitSet::clear | ( | int64_t | index | ) |

Clears a bit, allowing access beyond the current set size without changing the size.

## ◆ clear() [2/3]

void Lucene::OpenBitSet::clear | ( | int32_t | startIndex,
|  | int32_t | endIndex
| ) |  |

Clears a range of bits. Clearing past the end does not change the size of the set.

Parameters

  startIndex | lower index
  endIndex | one-past the last bit to clear

## ◆ clear() [3/3]

void Lucene::OpenBitSet::clear | ( | int64_t | startIndex,
|  | int64_t | endIndex
| ) |  |

Clears a range of bits. Clearing past the end does not change the size of the set.

Parameters

  startIndex | lower index
  endIndex | one-past the last bit to clear

## ◆ clone()

virtual LuceneObjectPtr Lucene::OpenBitSet::clone | ( | const LuceneObjectPtr & | other = `LuceneObjectPtr()` | ) |

virtual

Return clone of this object.

Parameters

  other | clone reference - null when called initially, then set in top virtual override.

Reimplemented from Lucene::LuceneObject.

## ◆ ensureCapacity()

void Lucene::OpenBitSet::ensureCapacity | ( | int64_t | numBits | ) |

Ensure that the LongArray is big enough to hold numBits, expanding it if necessary. getNumWords() is unchanged by this call.

## ◆ ensureCapacityWords()

void Lucene::OpenBitSet::ensureCapacityWords | ( | int32_t | numWords | ) |

Expand the LongArray with the size given as a number of words (64 bit longs). getNumWords() is unchanged by this call.

## ◆ equals()

virtual bool Lucene::OpenBitSet::equals | ( | const LuceneObjectPtr & | other | ) |

virtual

Returns true if both sets have the same bits set.

Reimplemented from Lucene::LuceneObject.

## ◆ expandingWordNum()

int32_t Lucene::OpenBitSet::expandingWordNum | ( | int64_t | index | ) |

protected

## ◆ fastClear() [1/2]

void Lucene::OpenBitSet::fastClear | ( | int32_t | index | ) |

Clears a bit. The index should be less than the OpenBitSet size.

## ◆ fastClear() [2/2]

void Lucene::OpenBitSet::fastClear | ( | int64_t | index | ) |

Clears a bit. The index should be less than the OpenBitSet size.

## ◆ fastFlip() [1/2]

void Lucene::OpenBitSet::fastFlip | ( | int32_t | index | ) |

Flips a bit. The index should be less than the OpenBitSet size.

## ◆ fastFlip() [2/2]

void Lucene::OpenBitSet::fastFlip | ( | int64_t | index | ) |

Flips a bit. The index should be less than the OpenBitSet size.

## ◆ fastGet() [1/2]

bool Lucene::OpenBitSet::fastGet | ( | int32_t | index | ) |

Returns true or false for the specified bit index. The index should be less than the OpenBitSet size.

## ◆ fastGet() [2/2]

bool Lucene::OpenBitSet::fastGet | ( | int64_t | index | ) |

Returns true or false for the specified bit index. The index should be less than the OpenBitSet size.

## ◆ fastSet() [1/2]

void Lucene::OpenBitSet::fastSet | ( | int32_t | index | ) |

Sets the bit at the specified index. The index should be less than the OpenBitSet size.

## ◆ fastSet() [2/2]

void Lucene::OpenBitSet::fastSet | ( | int64_t | index | ) |

Sets the bit at the specified index. The index should be less than the OpenBitSet size.

## ◆ flip() [1/2]

void Lucene::OpenBitSet::flip | ( | int64_t | index | ) |

Flips a bit, expanding the set size if necessary.

## ◆ flip() [2/2]

void Lucene::OpenBitSet::flip | ( | int64_t | startIndex,
|  | int64_t | endIndex
| ) |  |

Flips a range of bits, expanding the set size if necessary.

Parameters

  startIndex | lower index
  endIndex | one-past the last bit to flip

## ◆ flipAndGet() [1/2]

bool Lucene::OpenBitSet::flipAndGet | ( | int32_t | index | ) |

Flips a bit and returns the resulting bit value. The index should be less than the OpenBitSet size.

## ◆ flipAndGet() [2/2]

bool Lucene::OpenBitSet::flipAndGet | ( | int64_t | index | ) |

Flips a bit and returns the resulting bit value. The index should be less than the OpenBitSet size.

## ◆ get() [1/2]

bool Lucene::OpenBitSet::get | ( | int32_t | index | ) |

Returns true or false for the specified bit index.

## ◆ get() [2/2]

bool Lucene::OpenBitSet::get | ( | int64_t | index | ) |

Returns true or false for the specified bit index.

## ◆ getAndSet() [1/2]

bool Lucene::OpenBitSet::getAndSet | ( | int32_t | index | ) |

Sets a bit and returns the previous value. The index should be less than the OpenBitSet size.

## ◆ getAndSet() [2/2]

bool Lucene::OpenBitSet::getAndSet | ( | int64_t | index | ) |

Sets a bit and returns the previous value. The index should be less than the OpenBitSet size.

## ◆ getBit()

int32_t Lucene::OpenBitSet::getBit | ( | int32_t | index | ) |

Returns 1 if the bit is set, 0 if not. The index should be less than the OpenBitSet size.

## ◆ getBits()

LongArray Lucene::OpenBitSet::getBits | ( |  | ) |

Returns the long[] storing the bits.

## ◆ getClassName()

virtual String Lucene::OpenBitSet::getClassName | ( |  | ) |

inline virtual

Reimplemented from Lucene::DocIdSet.

Reimplemented in Lucene::OpenBitSetDISI.

## ◆ getNumWords()

int32_t Lucene::OpenBitSet::getNumWords | ( |  | ) |

Gets the number of longs in the array that are in use.

## ◆ hashCode()

virtual int32_t Lucene::OpenBitSet::hashCode | ( |  | ) |

virtual

Return hash code for this object.

Reimplemented from Lucene::LuceneObject.

## ◆ intersect()

void Lucene::OpenBitSet::intersect | ( | const OpenBitSetPtr & | other | ) |

this = this AND other

## ◆ intersectionCount()

static int64_t Lucene::OpenBitSet::intersectionCount | ( | const OpenBitSetPtr & | a,
|  | const OpenBitSetPtr & | b
| ) |  |

static

Returns the popcount or cardinality of the intersection of the two sets. Neither set is modified.

## ◆ intersects()

bool Lucene::OpenBitSet::intersects | ( | const OpenBitSetPtr & | other | ) |

Returns true if the sets have any elements in common.

## ◆ isCacheable()

virtual bool Lucene::OpenBitSet::isCacheable | ( |  | ) |

virtual

This DocIdSet implementation is cacheable.

Reimplemented from Lucene::DocIdSet.

## ◆ isEmpty()

bool Lucene::OpenBitSet::isEmpty | ( |  | ) |

Returns true if there are no set bits.

## ◆ iterator()

virtual DocIdSetIteratorPtr Lucene::OpenBitSet::iterator | ( |  | ) |

virtual

Provides a DocIdSetIterator to access the set. This implementation can return null or EmptyDocIdSet.iterator() if there are no docs that match.

Implements Lucene::DocIdSet.

## ◆ nextSetBit() [1/2]

int32_t Lucene::OpenBitSet::nextSetBit | ( | int32_t | index | ) |

Returns the index of the first set bit starting at the index specified. -1 is returned if there are no more set bits.

## ◆ nextSetBit() [2/2]

int64_t Lucene::OpenBitSet::nextSetBit | ( | int64_t | index | ) |

Returns the index of the first set bit starting at the index specified. -1 is returned if there are no more set bits.

## ◆ remove()

void Lucene::OpenBitSet::remove | ( | const OpenBitSetPtr & | other | ) |

Remove all elements set in other. this = this AND_NOT other.

## ◆ set() [1/2]

void Lucene::OpenBitSet::set | ( | int64_t | index | ) |

Sets a bit, expanding the set size if necessary.

## ◆ set() [2/2]

void Lucene::OpenBitSet::set | ( | int64_t | startIndex,
|  | int64_t | endIndex
| ) |  |

Sets a range of bits, expanding the set size if necessary.

Parameters

  startIndex | lower index
  endIndex | one-past the last bit to set

## ◆ setBits()

void Lucene::OpenBitSet::setBits | ( | LongArray | bits | ) |

Sets a new long[] to use as the bit storage.

## ◆ setNumWords()

void Lucene::OpenBitSet::setNumWords | ( | int32_t | numWords | ) |

Sets the number of longs in the array that are in use.

## ◆ shared_from_this()

boost::shared_ptr< OpenBitSet > Lucene::OpenBitSet::shared_from_this | ( |  | ) |

inline

## ◆ size()

int64_t Lucene::OpenBitSet::size | ( |  | ) |

Returns the current capacity of this set. Included for compatibility. This is not equal to cardinality.

## ◆ trimTrailingZeros()

void Lucene::OpenBitSet::trimTrailingZeros | ( |  | ) |

Lowers numWords, the number of words in use, by checking for trailing zero words.

## ◆ unionCount()

static int64_t Lucene::OpenBitSet::unionCount | ( | const OpenBitSetPtr & | a,
|  | const OpenBitSetPtr & | b
| ) |  |

static

Returns the popcount or cardinality of the union of the two sets. Neither set is modified.

## ◆ xorCount()

static int64_t Lucene::OpenBitSet::xorCount | ( | const OpenBitSetPtr & | a,
|  | const OpenBitSetPtr & | b
| ) |  |

static

Returns the popcount or cardinality of the exclusive-or of the two sets. Neither set is modified.

## Field Documentation

## ◆ bits

LongArray Lucene::OpenBitSet::bits

protected

## ◆ wlen

int32_t Lucene::OpenBitSet::wlen

protected

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

- OpenBitSet.h

clucene.sourceforge.net