Go to the documentation of this file.
63 for (
size_t i = 1; i <=
Size; i++)
bytewrite(&
Tree[pos(i)], bytesize(i), sequence[i - 1]);
65 for (
size_t m = 2; m <=
Size; m <<= 1) {
66 for (
size_t idx = m; idx <=
Size; idx += m) {
67 const uint64_t left =
byteread(&
Tree[pos(idx)], bytesize(idx));
68 const uint64_t right =
byteread(&
Tree[pos(idx - m / 2)], bytesize(idx - m / 2));
74 virtual uint64_t
prefix(
size_t idx) {
85 virtual void add(
size_t idx, int64_t inc) {
93 virtual size_t find(uint64_t *val) {
97 if (node + m >
Size)
continue;
99 const uint64_t value =
byteread(&
Tree[pos(node + m)], bytesize(node + m));
115 if (node + m >
Size)
continue;
117 const uint64_t value = (BOUND <<
rho(node + m)) -
byteread(&
Tree[pos(node + m)], bytesize(node + m));
128 virtual void push(uint64_t val) {
129 size_t p = pos(++
Size);
133 if ((
Size & 1) == 0) {
135 uint64_t inc =
byteread(&
Tree[pos(idx)], bytesize(idx));
160 static inline size_t bytesize(
size_t idx) {
return ((
rho(idx) +
BOUNDSIZE - 1) >> 3) + 1; }
162 static inline size_t holes(
size_t idx) {
167 #ifdef HFT_DISABLE_TRANSHUGE
168 return (idx >> (18 + (64 -
BOUNDSIZE) % 8));
170 return (idx >> (28 + (64 -
BOUNDSIZE) % 8));
174 static inline size_t pos(
size_t idx) {
176 constexpr
size_t NEXTBYTE = ((
BOUNDSIZE - 1) | (8 - 1)) + 1;
178 constexpr
size_t SMALL = ((
BOUNDSIZE - 1) >> 3) + 1;
179 constexpr
size_t MEDIUM = NEXTBYTE -
BOUNDSIZE + 1;
180 constexpr
size_t LARGE = MEDIUM + 8;
182 constexpr
size_t MULTIPLIER = 8 - SMALL - 1;
184 return idx * SMALL + (idx >> MEDIUM) + (idx >> LARGE) * MULTIPLIER + holes(idx);
188 os.write((
char *)&ft.
Size,
sizeof(uint64_t));
189 return os << ft.
Tree;
193 is.read((
char *)(&ft.
Size),
sizeof(uint64_t));
194 return is >> ft.
Tree;
virtual void add(size_t idx, int64_t inc)
Definition: FenwickByteF.hpp:85
virtual uint64_t prefix(size_t idx)
Definition: FenwickByteF.hpp:74
virtual void reserve(size_t space)
Definition: FenwickByteF.hpp:145
int rho(uint64_t word)
Definition: common.hpp:168
virtual size_t bitCount() const
Definition: FenwickByteF.hpp:157
Definition: Expandable.hpp:37
static constexpr size_t BOUNDSIZE
Definition: FenwickByteF.hpp:43
Definition: Expandable.hpp:43
virtual void grow(size_t space)
Definition: FenwickByteF.hpp:143
virtual size_t find(uint64_t *val)=0
uint64_t mask_lambda(uint64_t word)
Definition: common.hpp:216
Vector< uint8_t, AT > Tree
Definition: FenwickByteF.hpp:44
void bytewrite(void *const word, int length, uint64_t val)
Definition: common.hpp:265
virtual void trimToFit()
Definition: FenwickByteF.hpp:149
FenwickByteF()
Definition: FenwickByteF.hpp:52
void reserve(size_t capacity)
Definition: Vector.hpp:141
void size(size_t size)
Definition: Vector.hpp:178
virtual size_t size() const
Definition: FenwickByteF.hpp:155
void grow(size_t capacity)
Definition: Vector.hpp:153
friend std::ostream & operator<<(std::ostream &os, const FenwickByteF< BOUND, AT > &ft)
Definition: FenwickByteF.hpp:187
FenwickByteF(uint64_t sequence[], size_t size)
Definition: FenwickByteF.hpp:62
Definition: FenwickByteF.hpp:41
constexpr size_t ceil_log2_plus1(size_t n)
Definition: common.hpp:100
size_t bitCount() const
Definition: Vector.hpp:231
virtual void push(uint64_t val)
Definition: FenwickByteF.hpp:128
uint64_t clear_rho(uint64_t word)
Definition: common.hpp:194
Definition: SearchablePrefixSums.hpp:53
void resize(size_t size)
Definition: Vector.hpp:166
friend std::istream & operator>>(std::istream &is, FenwickByteF< BOUND, AT > &ft)
Definition: FenwickByteF.hpp:192
virtual void size(size_t space)
Definition: FenwickByteF.hpp:153
size_t Size
Definition: FenwickByteF.hpp:48
uint64_t mask_rho(uint64_t word)
Definition: common.hpp:208
virtual void resize(size_t space)
Definition: FenwickByteF.hpp:151
void bytewrite_inc(void *const word, uint64_t inc)
Definition: common.hpp:273
virtual void trim(size_t space)
Definition: FenwickByteF.hpp:147
void trim(size_t capacity)
Definition: Vector.hpp:127
virtual void pop()
Definition: FenwickByteF.hpp:141
virtual size_t compFind(uint64_t *val)
Definition: FenwickByteF.hpp:111
virtual size_t compFind(uint64_t *val)=0
uint64_t byteread(const void *const word, int length)
Definition: common.hpp:259
virtual size_t find(uint64_t *val)
Definition: FenwickByteF.hpp:93