Go to the documentation of this file.
31 #include "../util/Vector.hpp"
58 static constexpr
size_t BOUND = 64;
59 uint64_t *
const Vector;
61 SPS<BOUND, AT> SrcPrefSum;
84 virtual uint64_t
rank(
size_t pos) {
return SrcPrefSum.prefix(pos / 64) +
nu(Vector[pos / 64] & ((1ULL << (pos % 64)) - 1)); }
87 size_t idx = SrcPrefSum.find(&
rank);
88 uint64_t rank_chunk =
nu(Vector[idx]);
95 const size_t idx = SrcPrefSum.compFind(&
rank);
97 uint64_t rank_chunk =
nu(~Vector[idx]);
103 virtual uint64_t
update(
size_t index, uint64_t word) {
104 uint64_t old = Vector[index];
105 Vector[index] = word;
106 SrcPrefSum.add(index + 1,
nu(word) -
nu(old));
111 virtual bool set(
size_t index) {
112 uint64_t old = Vector[index / 64];
113 Vector[index / 64] |= uint64_t(1) << (index % 64);
115 if (Vector[index / 64] != old) {
116 SrcPrefSum.add(index / 64 + 1, 1);
124 uint64_t old = Vector[index / 64];
125 Vector[index / 64] &= ~(uint64_t(1) << (index % 64));
127 if (Vector[index / 64] != old) {
128 SrcPrefSum.add(index / 64 + 1, -1);
136 uint64_t old = Vector[index / 64];
137 Vector[index / 64] ^= uint64_t(1) << (index % 64);
138 bool was_set = Vector[index / 64] < old;
139 SrcPrefSum.add(index / 64 + 1, was_set ? -1 : 1);
144 virtual size_t size()
const {
return Size; }
146 virtual size_t bitCount()
const {
return SrcPrefSum.bitCount() -
sizeof(SrcPrefSum) * 8 +
sizeof(*
this) * 8 + ((Size + 63) & ~63); }
149 static size_t divRoundup(
size_t x,
size_t y) {
return (x + y - 1) / y; }
151 SPS<BOUND, AT> buildSrcPrefSum(
const uint64_t
bitvector[],
size_t size) {
152 unique_ptr<uint64_t[]> sequence = make_unique<uint64_t[]>(
size);
154 return SPS<BOUND, AT>(sequence.get(),
size);
158 os.write((
char *)&bv.Size,
sizeof(uint64_t));
159 return os << bv.SrcPrefSum << bv.Vector;
163 is.read((
char *)&bv.Size,
sizeof(uint64_t));
164 return is >> bv.SrcPrefSum >> bv.Vector;
AllocType
Definition: Vector.hpp:45
virtual bool clear(size_t index)
Definition: WordDynRankSel.hpp:123
WordDynRankSel(uint64_t bitvector[], size_t size)
Definition: WordDynRankSel.hpp:78
Definition: WordDynRankSel.hpp:56
virtual size_t select(uint64_t rank)
Definition: WordDynRankSel.hpp:86
Definition: Vector.hpp:47
virtual uint64_t rank(size_t pos)
Definition: WordDynRankSel.hpp:84
virtual bool set(size_t index)
Definition: WordDynRankSel.hpp:111
Definition: DynamicBitVector.hpp:41
Definition: Select.hpp:38
virtual bool toggle(size_t index)
Definition: WordDynRankSel.hpp:135
Definition: DynamicBitVector.hpp:31
virtual size_t selectZero(uint64_t rank)
Definition: WordDynRankSel.hpp:94
Definition: SelectZero.hpp:42
friend std::istream & operator>>(std::istream &is, WordDynRankSel< SPS, AT > &bv)
Definition: WordDynRankSel.hpp:162
virtual uint64_t rank(std::size_t pos)=0
int nu(uint64_t word)
Definition: common.hpp:339
virtual uint64_t update(size_t index, uint64_t word)
Definition: WordDynRankSel.hpp:103
uint64_t * bitvector() const
Definition: WordDynRankSel.hpp:80
friend std::ostream & operator<<(std::ostream &os, const WordDynRankSel< SPS, AT > &bv)
Definition: WordDynRankSel.hpp:157
virtual uint64_t rankZero(std::size_t pos)
Definition: Rank.hpp:70
virtual size_t bitCount() const
Definition: WordDynRankSel.hpp:146
virtual size_t size() const
Definition: WordDynRankSel.hpp:144
uint64_t select64(uint64_t x, uint64_t k)
Definition: common.hpp:372