It provides the various analytics on very large sequence of unsigned integers in constant time.
After adding to Cargo.toml, add this line to lib.rs or main.rs.
rust
extern crate wavelet_matrix;
See crate document top for further examples.
Given an unsigned integer sequence T, it provides the following queries.
.len()
:
.lookup(pos)
:
Counting is performed in O(1).
.count(start..end, value)
:
e == value
included in T[start..end]
.count_prefix(start..end, value, ignore_bit)
:
e >> ignore_bit == value >> ignore_bit
included in T[start..end]
192.168.10.0/24
. In this case, the ignore_bit will be 8..count_lt(start..end, value)
:
e < value
included in T[start..end]
.count_gt(start..end, value)
:
e > value
included in T[start..end]
.count_range(start..end, val_start..val_end)
:
val_start <= e < val_end
included in T[start..end]
Searching is performed in O(1) per a next index.
.search(start..end, value)
:
e == value
included in T[start..end]
.search_prefix(start..end, value, ignore_bit)
:
e >> ignore_bit == value >> ignore_bit
included in T[start..end]
Ranking is performed in roughly O(k), where k is the number of (value, count)
tuples.
.top_k(start..end, val_start..val_end, k)
:
val_start..val_end
..max_k(start..end, val_start..val_end, k)
:
val_start..val_end
..min_k(start..end, val_start..val_end, k)
:
val_start..val_end
..rank(pos, value)
: counts value included in T[0..pos].
.select(rank, value)
: return the position of the (rank+1)-th value
.bit_len()
..dim()
..top_k()
, .max_k()
and min_k()
..top_k()
, .max_k()
and min_k()
..search()
and .search_prefix()
..count()
, .count_prefix()
, .count_lt()
, .count_gt()
and .count_range()
.&Vec<u64>
, instead of Vec<u64>
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: