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


 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
BitVector.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2011 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  {
17  public:
19  BitVector(int32_t n = 0);
20 
21  BitVector(ByteArray bits, int32_t size);
22 
25  BitVector(DirectoryPtr d, const String& name);
26 
27  virtual ~BitVector();
28 
30 
31  protected:
32  ByteArray bits;
33  int32_t _size;
34  int32_t _count;
35 
36  static const uint8_t BYTE_COUNTS[]; // table of bits/byte
37 
38  public:
40  virtual LuceneObjectPtr clone(LuceneObjectPtr other = LuceneObjectPtr());
41 
43  void set(int32_t bit);
44 
46  bool getAndSet(int32_t bit);
47 
49  void clear(int32_t bit);
50 
52  bool get(int32_t bit);
53 
56  int32_t size();
57 
61  int32_t count();
62 
64  int32_t getRecomputedCount();
65 
68  void write(DirectoryPtr d, const String& name);
69 
74  BitVectorPtr subset(int32_t start, int32_t end);
75 
76  protected:
78  void writeBits(IndexOutputPtr output);
79 
81  void writeDgaps(IndexOutputPtr output);
82 
85  bool isSparse();
86 
88  void readBits(IndexInputPtr input);
89 
91  void readDgaps(IndexInputPtr input);
92  };
93 }
94 
95 #endif

clucene.sourceforge.net