Added FILE* functionality
[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(std::FILE * file);
36     DeltaVector(DeltaEncoder& encoder, usint universe_size);
37     ~DeltaVector();
38
39 //--------------------------------------------------------------------------
40
41     usint rank(usint value, bool at_least = false);
42
43     usint select(usint index);
44     usint selectNext();
45
46     pair_type valueAfter(usint value);
47     pair_type nextValue();
48
49     pair_type selectRun(usint index, usint max_length);
50     pair_type selectNextRun(usint max_length);
51
52     bool isSet(usint value);
53
54 //--------------------------------------------------------------------------
55
56     usint reportSize();
57 };
58
59
60 } // namespace CSA
61
62
63 #endif // DELTAVECTOR_H