The Wavelet Matrix is a space-efficient variant of Wavelet Tree data structure. - https://en.wikipedia.org/wiki/Wavelet_Tree
After adding to Cargo.toml, add this line to lib.rs or main.rs.
extern crate wavelet_matrix;
Add to main.rs: ``` use wavelet_matrix::*;
fn main() {
let vec: Vec
println!("Worked as expected!");
} ```
Given unsigned integer sequence A, it provides the following queries.
.len()
: returns the length of A..lookup(pos)
: returns the value at the position pos of A, A[pos]..count(pos_range, value)
: returns the number of the element which satisfies e == value
included in A[pos_range].count_prefix(pos_range, value, ignore_bit)
: returns the number of the element which satisfies e >> ignore_bit == value >> ignore_bit
included in A[pos_range]
172.22.0.0/16
.count_lt(pos_range, value)
: returns the number of the element which satisfies e < value
included in A[pos_range].count_gt(pos_range, value)
: returns the number of the element which satisfies e > value
included in A[pos_range].count_range(pos_range, val_range)
: returns the number of the element which satisfies val_range.start <= e < val_range.end
included in A[pos_range].rank(pos, value)
: counts value included in A[0..pos].
.select(rank, value)
: return the position of the (rank+1)-th value
.count()
, .count_prefix()
, .count_lt()
, .count_gt()
and .count_range()
.Add u128 support or arbitrary-length integer support
The fastest implementation on the planet
A Go package for myriad array operations using wavelet trees
excellent slides in Japanese
The original inventor's pdf: