Skip to main content

RangeFoldWithUpperBound

Struct RangeFoldWithUpperBound 

Source
pub struct RangeFoldWithUpperBound<K, M>
where M: AbelianGroup,
{ keys: Vec<K>, weights: Vec<M::T>, queries: Vec<(Range<usize>, K)>, }
Expand description

Offline range folds over entries whose keys are at most a query bound.

Fields§

§keys: Vec<K>§weights: Vec<M::T>§queries: Vec<(Range<usize>, K)>

Implementations§

Source§

impl<K, M> RangeFoldWithUpperBound<K, M>
where K: RadixSortKey + Ord, M: AbelianGroup,

Source

pub fn new(values: impl IntoIterator<Item = (K, M::T)>) -> Self

Examples found in repository?
crates/library_checker/src/data_structure/static_range_sum_with_upper_bound.rs (line 13)
8pub fn static_range_sum_with_upper_bound(reader: impl Read, writer: impl Write) {
9    prepare_io!(reader, writer);
10    sc!(n, q, a: [u32; iter n]);
11    type M = (AdditiveOperation<i64>, AdditiveOperation<i64>);
12    let mut fold: RangeFoldWithUpperBound<_, M> =
13        RangeFoldWithUpperBound::new(a.map(|a| (a, (1, i64::from(a)))));
14    for _ in 0..q {
15        sc!(l, r, x: u32);
16        fold.query(l..r, x);
17    }
18    pp!(@ittup fold.execute());
19}
Source

pub fn query(&mut self, range: Range<usize>, upper_bound: K) -> usize

Examples found in repository?
crates/library_checker/src/data_structure/static_range_sum_with_upper_bound.rs (line 16)
8pub fn static_range_sum_with_upper_bound(reader: impl Read, writer: impl Write) {
9    prepare_io!(reader, writer);
10    sc!(n, q, a: [u32; iter n]);
11    type M = (AdditiveOperation<i64>, AdditiveOperation<i64>);
12    let mut fold: RangeFoldWithUpperBound<_, M> =
13        RangeFoldWithUpperBound::new(a.map(|a| (a, (1, i64::from(a)))));
14    for _ in 0..q {
15        sc!(l, r, x: u32);
16        fold.query(l..r, x);
17    }
18    pp!(@ittup fold.execute());
19}
Source

pub fn execute(self) -> Vec<M::T>

Examples found in repository?
crates/library_checker/src/data_structure/static_range_sum_with_upper_bound.rs (line 18)
8pub fn static_range_sum_with_upper_bound(reader: impl Read, writer: impl Write) {
9    prepare_io!(reader, writer);
10    sc!(n, q, a: [u32; iter n]);
11    type M = (AdditiveOperation<i64>, AdditiveOperation<i64>);
12    let mut fold: RangeFoldWithUpperBound<_, M> =
13        RangeFoldWithUpperBound::new(a.map(|a| (a, (1, i64::from(a)))));
14    for _ in 0..q {
15        sc!(l, r, x: u32);
16        fold.query(l..r, x);
17    }
18    pp!(@ittup fold.execute());
19}

Auto Trait Implementations§

§

impl<K, M> Freeze for RangeFoldWithUpperBound<K, M>
where Vec<K>: Freeze, Vec<<M as Magma>::T>: Freeze, Vec<(Range<usize>, K)>: Freeze,

§

impl<K, M> RefUnwindSafe for RangeFoldWithUpperBound<K, M>

§

impl<K, M> Send for RangeFoldWithUpperBound<K, M>
where Vec<K>: Send, Vec<<M as Magma>::T>: Send, Vec<(Range<usize>, K)>: Send,

§

impl<K, M> Sync for RangeFoldWithUpperBound<K, M>
where Vec<K>: Sync, Vec<<M as Magma>::T>: Sync, Vec<(Range<usize>, K)>: Sync,

§

impl<K, M> Unpin for RangeFoldWithUpperBound<K, M>
where Vec<K>: Unpin, Vec<<M as Magma>::T>: Unpin, Vec<(Range<usize>, K)>: Unpin,

§

impl<K, M> UnsafeUnpin for RangeFoldWithUpperBound<K, M>
where Vec<K>: UnsafeUnpin, Vec<<M as Magma>::T>: UnsafeUnpin, Vec<(Range<usize>, K)>: UnsafeUnpin,

§

impl<K, M> UnwindSafe for RangeFoldWithUpperBound<K, M>
where Vec<K>: UnwindSafe, Vec<<M as Magma>::T>: UnwindSafe, Vec<(Range<usize>, K)>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> ToArrayVecScalar for T

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.