Struct nekolib::ds::wavelet_matrix::WaveletMatrix
source · pub struct WaveletMatrix<I> { /* private fields */ }
Expand description
wavelet matrix。
整数に関する多くの区間クエリを処理できる。
Examples
use nekolib::ds::WaveletMatrix;
use nekolib::traits::{Count3way, FindNth, Quantile};
let wm: WaveletMatrix<u32> = vec![1, 8, 4, 9, 2, 7, 5, 2].into();
assert_eq!(wm.count_3way(2.., 5).lt(), 3); // [4, _, 2, _, _, _, 2]
let c3 = wm.count_3way(..6, 2..=7); // [1, 8, 4, 9, 2, 7]
assert_eq!(c3.lt(), 1); // [1, _, _, _, _, _]
assert_eq!(c3.eq(), 3); // [_, _, 4, _, 2, 7]
assert_eq!(c3.gt(), 2); // [_, 8, _, 9, _, _]
assert_eq!(c3.le(), 4);
assert_eq!(c3.ge(), 5);
assert_eq!(wm.quantile(2..=4, 0), Some(2)); // [_, _, 2]
assert_eq!(wm.quantile(2..=4, 1), Some(4)); // [4, _, _]
assert_eq!(wm.quantile(2..=4, 2), Some(9)); // [_, 9, _]
assert_eq!(wm.quantile(2..=4, 3), None);
assert_eq!(wm.find_nth(3.., 2, 0), Some(4));
assert_eq!(wm.find_nth(3.., 2, 1), Some(7));
assert_eq!(wm.find_nth(4.., 2, 0), Some(4));
assert_eq!(wm.find_nth(5.., 2, 0), Some(7));
assert_eq!(wm.find_nth(5.., 2, 1), None);
Implementations§
source§impl<I: WmInt> WaveletMatrix<I>
impl<I: WmInt> WaveletMatrix<I>
pub fn xored_quantile( &self, range: impl RangeBounds<usize>, n: usize, x: I ) -> Option<I>
Trait Implementations§
source§impl<I: WmInt> Count<I> for WaveletMatrix<I>
impl<I: WmInt> Count<I> for WaveletMatrix<I>
source§impl<I: WmInt> Count<RangeInclusive<I>> for WaveletMatrix<I>
impl<I: WmInt> Count<RangeInclusive<I>> for WaveletMatrix<I>
fn count( &self, range: impl RangeBounds<usize>, value: RangeInclusive<I> ) -> usize
source§impl<I: WmInt> Count3way<I> for WaveletMatrix<I>
impl<I: WmInt> Count3way<I> for WaveletMatrix<I>
fn count_3way( &self, range: impl RangeBounds<usize>, value: I ) -> Count3wayResult
source§impl<I: WmInt> Count3way<RangeInclusive<I>> for WaveletMatrix<I>
impl<I: WmInt> Count3way<RangeInclusive<I>> for WaveletMatrix<I>
fn count_3way( &self, range: impl RangeBounds<usize>, value: RangeInclusive<I> ) -> Count3wayResult
source§impl<I: WmInt> FindNth<I> for WaveletMatrix<I>
impl<I: WmInt> FindNth<I> for WaveletMatrix<I>
Auto Trait Implementations§
impl<I> RefUnwindSafe for WaveletMatrix<I>where I: RefUnwindSafe,
impl<I> Send for WaveletMatrix<I>where I: Send,
impl<I> Sync for WaveletMatrix<I>where I: Sync,
impl<I> Unpin for WaveletMatrix<I>where I: Unpin,
impl<I> UnwindSafe for WaveletMatrix<I>where I: UnwindSafe,
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