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


BitVector.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2014 Alan Wright. All rights reserved.
3 // Distributable under the terms of either the Apache License (Version 2.0)
4 // or the GNU Lesser General Public License.
6 
7 #ifndef BITVECTOR_H
8 #define BITVECTOR_H
9 
10 #include "LuceneObject.h"
11 
12 namespace Lucene {
13 
15 class LPPAPI BitVector : public LuceneObject {
16 public:
18  BitVector(int32_t n = 0);
19 
20  BitVector(ByteArray bits, int32_t size);
21 
24  BitVector(const DirectoryPtr& d, const String& name);
25 
26  virtual ~BitVector();
27 
29 
30 protected:
31  ByteArray bits;
32  int32_t _size;
33  int32_t _count;
34 
35  static const uint8_t BYTE_COUNTS[]; // table of bits/byte
36 
37 public:
40 
42  void set(int32_t bit);
43 
45  bool getAndSet(int32_t bit);
46 
48  void clear(int32_t bit);
49 
51  bool get(int32_t bit);
52 
55  int32_t size();
56 
60  int32_t count();
61 
63  int32_t getRecomputedCount();
64 
67  void write(const DirectoryPtr& d, const String& name);
68 
73  BitVectorPtr subset(int32_t start, int32_t end);
74 
75 protected:
77  void writeBits(const IndexOutputPtr& output);
78 
80  void writeDgaps(const IndexOutputPtr& output);
81 
84  bool isSparse();
85 
87  void readBits(const IndexInputPtr& input);
88 
90  void readDgaps(const IndexInputPtr& input);
91 };
92 
93 }
94 
95 #endif
Lucene::BitVector::writeBits
void writeBits(const IndexOutputPtr &output)
Write as a bit set.
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Lucene::BitVector::getAndSet
bool getAndSet(int32_t bit)
Sets the value of bit to true, and returns true if bit was already set.
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition: LuceneTypes.h:539
Lucene::BitVector::write
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 B...
Lucene::BitVector
Optimized implementation of a vector of bits.
Definition: BitVector.h:15
Lucene::BitVector::~BitVector
virtual ~BitVector()
Lucene::BitVector::get
bool get(int32_t bit)
Returns true if bit is one and false if it is zero.
Lucene::BitVectorPtr
boost::shared_ptr< BitVector > BitVectorPtr
Definition: LuceneTypes.h:523
Lucene::BitVector::subset
BitVectorPtr subset(int32_t start, int32_t end)
Retrieve a subset of this BitVector.
Lucene::BitVector::readBits
void readBits(const IndexInputPtr &input)
Read as a bit set.
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::BitVector::_count
int32_t _count
Definition: BitVector.h:33
Lucene::BitVector::size
int32_t size()
Returns the number of bits in this vector. This is also one greater than the number of the largest va...
Lucene::LuceneObject
Base class for all Lucene classes.
Definition: LuceneObject.h:31
Lucene::BitVector::readDgaps
void readDgaps(const IndexInputPtr &input)
Read as a d-gaps list.
Lucene::IndexInputPtr
boost::shared_ptr< IndexInput > IndexInputPtr
Definition: LuceneTypes.h:493
Lucene::BitVector::writeDgaps
void writeDgaps(const IndexOutputPtr &output)
Write as a d-gaps list.
Lucene::BitVector::isSparse
bool isSparse()
Indicates if the bit vector is sparse and should be saved as a d-gaps list, or dense,...
Lucene::BitVector::getRecomputedCount
int32_t getRecomputedCount()
For testing.
Lucene::DirectoryPtr
boost::shared_ptr< Directory > DirectoryPtr
Definition: LuceneTypes.h:489
Lucene::BitVector::count
int32_t count()
Returns the total number of one bits in this vector. This is efficiently computed and cached,...
Lucene::BitVector::BitVector
BitVector(ByteArray bits, int32_t size)
Lucene::BitVector::_size
int32_t _size
Definition: BitVector.h:32
Lucene::BitVector::clone
virtual LuceneObjectPtr clone(const LuceneObjectPtr &other=LuceneObjectPtr())
Clone this vector.
Lucene::BitVector::BitVector
BitVector(int32_t n=0)
Constructs a vector capable of holding n bits.
Lucene::BitVector::bits
ByteArray bits
Definition: BitVector.h:28
Lucene::BitVector::set
void set(int32_t bit)
Sets the value of bit to one.
Lucene::BitVector::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.
Lucene::BitVector::clear
void clear(int32_t bit)
Sets the value of bit to zero.
Lucene::IndexOutputPtr
boost::shared_ptr< IndexOutput > IndexOutputPtr
Definition: LuceneTypes.h:494
LuceneObject.h

clucene.sourceforge.net