MCPcopy Create free account
hub / github.com/BirolLab/abyss / BitArray

Class BitArray

FMIndex/bit_array.h:33–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31};
32
33class BitArray {
34
35private:
36enum {
37 BLOCK_BITNUM = 64,
38 TABLE_INTERVAL = 4
39};
40
41public:
42 BitArray();
43 ~BitArray();
44 BitArray(uint64_t size);
45 uint64_t length() const;
46 uint64_t one_num() const;
47
48 void Init(uint64_t size);
49 void Clear();
50 void SetBit(uint64_t bit, uint64_t pos);
51 void Build();
52 uint64_t Rank(uint64_t bit, uint64_t pos) const;
53 uint64_t Select(uint64_t bit, uint64_t rank) const;
54 uint64_t Lookup(uint64_t pos) const;
55
56 static uint64_t PopCount(uint64_t x);
57 static uint64_t PopCountMask(uint64_t x, uint64_t offset);
58 static uint64_t SelectInBlock(uint64_t x, uint64_t rank);
59 static uint64_t GetBitNum(uint64_t one_num, uint64_t num, uint64_t bit);
60 void PrintForDebug(std::ostream& os) const;
61
62 void Save(std::ostream& os) const;
63 void Load(std::istream& is);
64
65private:
66 uint64_t RankOne(uint64_t pos) const;
67 uint64_t SelectOutBlock(uint64_t bit, uint64_t& rank) const;
68
69private:
70 std::vector<uint64_t> bit_blocks_;
71 std::vector<uint64_t> rank_tables_;
72 uint64_t length_;
73 uint64_t one_num_;
74};
75
76}
77

Callers 1

assignMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected