pub struct WaveletMatrix { /* private fields */ }
Implementations§
Source§impl WaveletMatrix
impl WaveletMatrix
Sourcepub fn new<T>(v: Vec<T>, bit_length: usize) -> Selfwhere
T: Clone + RankSelectDictionaries,
pub fn new<T>(v: Vec<T>, bit_length: usize) -> Selfwhere
T: Clone + RankSelectDictionaries,
Examples found in repository?
More examples
crates/competitive/src/data_structure/wavelet_matrix.rs (line 34)
29 pub fn new_with_init<T, F>(v: Vec<T>, bit_length: usize, mut f: F) -> Self
30 where
31 T: Clone + RankSelectDictionaries,
32 F: FnMut(usize, usize, T),
33 {
34 let this = Self::new(v.clone(), bit_length);
35 for (mut k, v) in v.into_iter().enumerate() {
36 for (d, &(c, ref b)) in this.table.iter().rev().enumerate().rev() {
37 if v.access(d) {
38 k = c + b.rank1(k);
39 } else {
40 k = b.rank0(k);
41 }
42 f(d, k, v.clone());
43 }
44 }
45 this
46 }
pub fn new_with_init<T, F>(v: Vec<T>, bit_length: usize, f: F) -> Self
Sourcepub fn rank(&self, val: usize, range: Range<usize>) -> usize
pub fn rank(&self, val: usize, range: Range<usize>) -> usize
the number of val in range
Examples found in repository?
crates/competitive/src/data_structure/wavelet_matrix.rs (line 75)
74 pub fn select(&self, val: usize, k: usize) -> Option<usize> {
75 if self.rank(val, 0..self.len) <= k {
76 return None;
77 }
78 let mut i = 0;
79 for (d, &(c, ref b)) in self.table.iter().rev().enumerate().rev() {
80 if val.access(d) {
81 i = c + b.rank1(i);
82 } else {
83 i = b.rank0(i);
84 }
85 }
86 i += k;
87 for &(c, ref b) in self.table.iter().rev() {
88 if i >= c {
89 i = b.select1(i - c).unwrap();
90 } else {
91 i = b.select0(i).unwrap();
92 }
93 }
94 Some(i)
95 }
Sourcepub fn quantile(&self, range: Range<usize>, k: usize) -> usize
pub fn quantile(&self, range: Range<usize>, k: usize) -> usize
get k-th smallest value in range
Sourcepub fn quantile_outer(&self, range: Range<usize>, k: usize) -> usize
pub fn quantile_outer(&self, range: Range<usize>, k: usize) -> usize
get k-th smallest value out of range
Sourcepub fn rank_lessthan(&self, val: usize, range: Range<usize>) -> usize
pub fn rank_lessthan(&self, val: usize, range: Range<usize>) -> usize
the number of value less than val in range
Sourcepub fn rank_range(&self, valrange: Range<usize>, range: Range<usize>) -> usize
pub fn rank_range(&self, valrange: Range<usize>, range: Range<usize>) -> usize
the number of valrange in range
pub fn query_less_than<F>(&self, val: usize, range: Range<usize>, f: F)
Trait Implementations§
Source§impl Clone for WaveletMatrix
impl Clone for WaveletMatrix
Source§fn clone(&self) -> WaveletMatrix
fn clone(&self) -> WaveletMatrix
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for WaveletMatrix
impl RefUnwindSafe for WaveletMatrix
impl Send for WaveletMatrix
impl Sync for WaveletMatrix
impl Unpin for WaveletMatrix
impl UnwindSafe for WaveletMatrix
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more