#include <FenwickBitF.hpp>
template<size_t BOUND, AllocType AT = MALLOC>
class sux::util::FenwickBitF< BOUND, AT >
A bit-compressed Fenwick tree in classical layout.
- Template Parameters
-
BOUND | maximum representable value (at most the maximum value of a uint64_t ). |
AT | a type of memory allocation out of AllocType. |
◆ FenwickBitF() [1/2]
template<size_t BOUND, AllocType AT = MALLOC>
Creates a new instance with no values (empty tree).
◆ FenwickBitF() [2/2]
template<size_t BOUND, AllocType AT = MALLOC>
Creates a new instance with given vector of values.
Note that the provided sequence is read at construction time but it will not be referenced afterwards.
- Parameters
-
sequence | a sequence of nonnegative integers smaller than or equal to the template parameter BOUND . |
size | the number of elements in the sequence. |
◆ add()
template<size_t BOUND, AllocType AT = MALLOC>
Increment an element of the sequence (not the tree).
- Parameters
-
idx | index of the element. |
c | value to sum. |
You are allowed to use negative values for the increment, but elements of of the sequence must remain all nonnegative.
Implements sux::util::SearchablePrefixSums.
◆ bitCount()
template<size_t BOUND, AllocType AT = MALLOC>
◆ compFind() [1/3]
template<size_t BOUND, AllocType AT = MALLOC>
Search the length of the longest prefix whose complemented sum is less than or equal to a given bound.
- Parameters
-
val | bound for the complemented prefix sum. |
If val
is an l-value reference its value will be replaced with the excess, that is, the difference between val
and the complemented longest prefix sum described above.
This method returns zero if there are no prefixes whose complemented sum is greater or equal to val
.
Implements sux::util::SearchablePrefixSums.
◆ compFind() [2/3]
template<size_t BOUND, AllocType AT = MALLOC>
virtual size_t sux::util::SearchablePrefixSums::compFind |
Search the length of the longest prefix whose complemented sum is less than or equal to a given bound.
- Parameters
-
val | bound for the complemented prefix sum. |
If val
is an l-value reference its value will be replaced with the excess, that is, the difference between val
and the complemented longest prefix sum described above.
This method returns zero if there are no prefixes whose complemented sum is greater or equal to val
.
◆ compFind() [3/3]
template<size_t BOUND, AllocType AT = MALLOC>
size_t sux::util::SearchablePrefixSums::compFind |
|
inline |
◆ find() [1/3]
template<size_t BOUND, AllocType AT = MALLOC>
Search the length of the longest prefix whose sum is less than or equal to a given bound.
- Parameters
-
val | bound for the prefix sum. |
If val
is an l-value reference its value will be replaced with the excess, that is, the difference between val
and the longest prefix sum described above.
This method returns zero if there are no prefixes whose sum is greater or equal to val
.
Implements sux::util::SearchablePrefixSums.
◆ find() [2/3]
template<size_t BOUND, AllocType AT = MALLOC>
virtual size_t sux::util::SearchablePrefixSums::find |
Search the length of the longest prefix whose sum is less than or equal to a given bound.
- Parameters
-
val | bound for the prefix sum. |
If val
is an l-value reference its value will be replaced with the excess, that is, the difference between val
and the longest prefix sum described above.
This method returns zero if there are no prefixes whose sum is greater or equal to val
.
◆ find() [3/3]
template<size_t BOUND, AllocType AT = MALLOC>
size_t sux::util::SearchablePrefixSums::find |
|
inline |
◆ grow()
template<size_t BOUND, AllocType AT = MALLOC>
Enlarges this expandable so that it can contain a given number of elements, plus possibly extra space.
If the current capacity is sufficient, nothing happens. Otherwise, the expandable is enlarged, usually to the maximum between the provided capacity and 50% more than the current capacity.
- Parameters
-
capacity | the desired new capacity. |
Implements sux::util::Expandable.
◆ pop()
template<size_t BOUND, AllocType AT = MALLOC>
◆ prefix()
template<size_t BOUND, AllocType AT = MALLOC>
Compute the prefix sum.
- Parameters
-
length | length of the prefix sum (from 0 to size(), included). |
- Returns
- the sum of the elements in the range
(0 .. length]
.
Implements sux::util::SearchablePrefixSums.
◆ push()
template<size_t BOUND, AllocType AT = MALLOC>
◆ reserve()
template<size_t BOUND, AllocType AT = MALLOC>
Enlarges this expandable so that it can contain a given number of elements without memory reallocation.
If the current capacity is sufficient, nothing happens. Otherwise, the expandable is enlarged to the provided capacity.
- Parameters
-
capacity | the desired new capacity. |
Implements sux::util::Expandable.
◆ resize()
template<size_t BOUND, AllocType AT = MALLOC>
Changes the expandable size to the given value.
If the argument is smaller than or equal to the current size, there is no memory reallocation. Otherwise, reallocation happens with grow().
- Parameters
-
size | the desired new size. |
Implements sux::util::Expandable.
◆ size() [1/2]
template<size_t BOUND, AllocType AT = MALLOC>
◆ size() [2/2]
template<size_t BOUND, AllocType AT = MALLOC>
Changes the expandable size and capacity to the given value.
- Parameters
-
size | the desired new size and capacity. |
Implements sux::util::Expandable.
◆ trim()
template<size_t BOUND, AllocType AT = MALLOC>
Trims the data structure to the given capacity
provided it is larger than the current size.
- Parameters
-
capacity | the new desired capacity. |
Implements sux::util::Expandable.
◆ trimToFit()
template<size_t BOUND, AllocType AT = MALLOC>
◆ operator<<
template<size_t BOUND, AllocType AT = MALLOC>
std::ostream& operator<< |
( |
std::ostream & |
os, |
|
|
const FenwickBitF< BOUND, AT > & |
ft |
|
) |
| |
|
friend |
◆ operator>>
template<size_t BOUND, AllocType AT = MALLOC>
std::istream& operator>> |
( |
std::istream & |
is, |
|
|
FenwickBitF< BOUND, AT > & |
ft |
|
) |
| |
|
friend |
◆ BOUNDSIZE
template<size_t BOUND, AllocType AT = MALLOC>
◆ END_PADDING
template<size_t BOUND, AllocType AT = MALLOC>
◆ Size
template<size_t BOUND, AllocType AT = MALLOC>
◆ STARTING_OFFSET
template<size_t BOUND, AllocType AT = MALLOC>
◆ Tree
template<size_t BOUND, AllocType AT = MALLOC>
The documentation for this class was generated from the following file: