Struct nekolib::ds::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>

source

pub fn xored_quantile( &self, range: impl RangeBounds<usize>, n: usize, x: I ) -> Option<I>

source§

impl<I: WmInt> WaveletMatrix<I>

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn rank(&self, end: usize, value: I) -> usize

source

pub fn select(&self, value: I, n: usize) -> Option<usize>

Trait Implementations§

source§

impl<I: WmInt> Count<I> for WaveletMatrix<I>

source§

fn count(&self, range: impl RangeBounds<usize>, value: I) -> usize

source§

impl<I: WmInt> Count<RangeInclusive<I>> for WaveletMatrix<I>

source§

fn count( &self, range: impl RangeBounds<usize>, value: RangeInclusive<I> ) -> usize

source§

impl<I: WmInt> Count3way<I> for WaveletMatrix<I>

source§

fn count_3way( &self, range: impl RangeBounds<usize>, value: I ) -> Count3wayResult

source§

impl<I: WmInt> Count3way<RangeInclusive<I>> for WaveletMatrix<I>

source§

fn count_3way( &self, range: impl RangeBounds<usize>, value: RangeInclusive<I> ) -> Count3wayResult

source§

impl<I: WmInt> FindNth<I> for WaveletMatrix<I>

source§

fn find_nth( &self, range: impl RangeBounds<usize>, value: I, n: usize ) -> Option<usize>

source§

impl<I: WmInt> From<Vec<I, Global>> for WaveletMatrix<I>

source§

fn from(orig: Vec<I>) -> Self

Converts to this type from the input type.
source§

impl<I: WmInt> Index<usize> for WaveletMatrix<I>

§

type Output = I

The returned type after indexing.
source§

fn index(&self, i: usize) -> &I

Performs the indexing (container[index]) operation. Read more
source§

impl<I: WmInt> Quantile for WaveletMatrix<I>

§

type Output = I

source§

fn quantile(&self, range: impl RangeBounds<usize>, n: usize) -> Option<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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V