e0692d6767cab9eef375554e9d8ef234931653fb
[SXSI/TextCollection.git] / incbwt / bits / deltavector.h
1 #ifndef DELTAVECTOR_H
2 #define DELTAVECTOR_H
3
4 #include <fstream>
5
6 #include "bitvector.h"
7
8
9 namespace CSA
10 {
11
12
13 /*
14   This class is used to construct a DeltaVector.
15 */
16
17 class DeltaEncoder : public VectorEncoder
18 {
19   public:
20     DeltaEncoder(usint block_bytes, usint superblock_size = VectorEncoder::SUPERBLOCK_SIZE);
21     ~DeltaEncoder();
22
23     void setBit(usint value);
24 };
25
26
27 /*
28   This is a gap-encoded bit vector using delta coding.
29 */
30
31 class DeltaVector : public BitVector
32 {
33   public:
34     DeltaVector(std::ifstream& file);
35     DeltaVector(DeltaEncoder& encoder, usint universe_size);
36     ~DeltaVector();
37
38 //--------------------------------------------------------------------------
39
40     usint rank(usint value, bool at_least = false);
41
42     usint select(usint index);
43     usint selectNext();
44
45     pair_type valueAfter(usint value);
46     pair_type nextValue();
47
48     pair_type selectRun(usint index, usint max_length);
49     pair_type selectNextRun(usint max_length);
50
51     bool isSet(usint value);
52
53 //--------------------------------------------------------------------------
54
55     usint reportSize();
56 };
57
58
59 } // namespace CSA
60
61
62 #endif // DELTAVECTOR_H