Sux
|
#include <SearchablePrefixSums.hpp>
Public Member Functions | |
virtual | ~SearchablePrefixSums ()=default |
virtual uint64_t | prefix (size_t length)=0 |
virtual void | add (size_t idx, int64_t c)=0 |
virtual size_t | find (uint64_t *val)=0 |
size_t | find (uint64_t val) |
virtual size_t | compFind (uint64_t *val)=0 |
size_t | compFind (uint64_t val) |
virtual void | push (uint64_t val)=0 |
virtual void | pop ()=0 |
virtual size_t | size () const =0 |
virtual size_t | bitCount () const =0 |
An interface for classes implementing searchable prefix sums.
A searchable prefix-sums data structure maintains a list of nonnegative values and makes it possible to compute sum of prefixes and find the length of the longest prefix sum smaller than or equal to a given bound.
Indices into the list start (oddly) from 1 and end at size(), included, because the typical implementation is by a Fenwick tree, for which indexing from 1 is natural.
An implementation of SearchablePrefixSums should be serializable and deserializable with:
|
virtualdefault |
|
pure virtual |
Increment an element of the sequence (not the tree).
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.
Implemented in sux::util::FenwickByteL< BOUND, AT >, sux::util::FenwickBitL< BOUND, AT >, sux::util::FenwickFixedL< BOUND, AT >, sux::util::FenwickByteF< BOUND, AT >, sux::util::FenwickBitF< BOUND, AT >, and sux::util::FenwickFixedF< BOUND, AT >.
|
pure virtual |
Returns an estimate of the size (in bits) of this structure.
Implemented in sux::util::FenwickByteL< BOUND, AT >, sux::util::FenwickBitL< BOUND, AT >, sux::util::FenwickFixedL< BOUND, AT >, sux::util::FenwickByteF< BOUND, AT >, sux::util::FenwickBitF< BOUND, AT >, and sux::util::FenwickFixedF< BOUND, AT >.
|
pure virtual |
Search the length of the longest prefix whose complemented sum is less than or equal to a given bound.
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
.
Implemented in sux::util::FenwickByteL< BOUND, AT >, sux::util::FenwickBitL< BOUND, AT >, sux::util::FenwickFixedL< BOUND, AT >, sux::util::FenwickByteF< BOUND, AT >, sux::util::FenwickBitF< BOUND, AT >, and sux::util::FenwickFixedF< BOUND, AT >.
|
inline |
|
pure virtual |
Search the length of the longest prefix whose sum is less than or equal to a given bound.
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
.
Implemented in sux::util::FenwickByteL< BOUND, AT >, sux::util::FenwickBitL< BOUND, AT >, sux::util::FenwickFixedL< BOUND, AT >, sux::util::FenwickByteF< BOUND, AT >, sux::util::FenwickBitF< BOUND, AT >, and sux::util::FenwickFixedF< BOUND, AT >.
|
inline |
|
pure virtual |
Remove the last value of the sequence.
This method does not release the allocated space.
Implemented in sux::util::FenwickByteL< BOUND, AT >, sux::util::FenwickBitL< BOUND, AT >, sux::util::FenwickFixedL< BOUND, AT >, sux::util::FenwickByteF< BOUND, AT >, sux::util::FenwickBitF< BOUND, AT >, and sux::util::FenwickFixedF< BOUND, AT >.
|
pure virtual |
Compute the prefix sum.
length | length of the prefix sum (from 0 to size(), included). |
(0 .. length]
. Implemented in sux::util::FenwickBitL< BOUND, AT >, sux::util::FenwickByteL< BOUND, AT >, sux::util::FenwickFixedL< BOUND, AT >, sux::util::FenwickByteF< BOUND, AT >, sux::util::FenwickBitF< BOUND, AT >, and sux::util::FenwickFixedF< BOUND, AT >.
|
pure virtual |
Append a value to the sequence
val | value to append. |
Append a new value to the sequence and update the tree.
Implemented in sux::util::FenwickByteL< BOUND, AT >, sux::util::FenwickBitL< BOUND, AT >, sux::util::FenwickFixedL< BOUND, AT >, sux::util::FenwickBitF< BOUND, AT >, sux::util::FenwickByteF< BOUND, AT >, and sux::util::FenwickFixedF< BOUND, AT >.
|
pure virtual |
Returns the length of the sequence (i.e., the size of the tree).
Implemented in sux::util::FenwickByteL< BOUND, AT >, sux::util::FenwickBitL< BOUND, AT >, sux::util::FenwickFixedL< BOUND, AT >, sux::util::FenwickByteF< BOUND, AT >, sux::util::FenwickBitF< BOUND, AT >, and sux::util::FenwickFixedF< BOUND, AT >.