Efficient representation of a wavelet tree, supporting various static range queries.
More...
|
|
| WaveletArray () |
| | Creates an empty WaveletArray.
|
| |
|
| WaveletArray (std::vector< T > &&data) |
| | Creates a WaveletArray by consuming an array of elements.
|
| |
|
size_type | size () const |
| | Returns the number of elements.
|
| |
| T | get (size_type idx) const |
| | Returns the element at the given index.
|
| |
| T | range_nth (size_type left, size_type right, size_type n) const |
| | Returns the 0-indexed n-th smallest element in the range [left, right).
|
| |
| size_type | range_count (size_type left, size_type right, T val) const |
| | Returns the number of the given value in the range [left, right).
|
| |
| size_type | range_count_between (size_type left, size_type right, T low, T high) const |
| | Returns the number of elements in the range [left, right) whose values are between [low, high].
|
| |
template<typename T, int M = std::numeric_limits<T>::digits>
class cplib::WaveletArray< T, M >
Efficient representation of a wavelet tree, supporting various static range queries.
Each level of the wavelet tree is stored as a BitDict.
- Template Parameters
-
| T | Type of elements. Must be an unsigned integer type. |
| M | Specify that all elements are integers in \([0,2^M-1]\). It is propotional to the complexity of most operations and should be set as small as possible. |
template<typename T , int M = std::numeric_limits<T>::digits>
| size_type cplib::WaveletArray< T, M >::range_count_between |
( |
size_type |
left, |
|
|
size_type |
right, |
|
|
T |
low, |
|
|
T |
high |
|
) |
| const |
|
inline |
Returns the number of elements in the range [left, right) whose values are between [low, high].
Requires 0 <= left < right <= size() and 0 <= low <= high <= max_value. Note that the value range is inclusive, to allow using the maximum value of the type T. Calls \(O(M)\) BitDict operations.