Skip to main content

Accumulate

Struct Accumulate 

Source
pub struct Accumulate<M>
where M: Monoid,
{ data: Vec<M::T>, }
Expand description

Accumlated data

Fields§

§data: Vec<M::T>

Implementations§

Source§

impl<M> Accumulate<M>
where M: Monoid,

Source

pub fn from_vec(data: Vec<M::T>) -> Self

Source

pub fn accumulate(&self, k: usize) -> M::T

Return fold of [0, k)

Source§

impl<M> Accumulate<M>
where M: Group,

Source

pub fn fold<R>(&self, range: R) -> M::T
where R: RangeBounds<usize>,

Return fold of range

Examples found in repository?
crates/library_checker/src/data_structure/static_range_sum.rs (line 11)
5pub fn static_range_sum(reader: impl Read, writer: impl Write) {
6    prepare_io!(reader, writer);
7    sc!(n, q, a: [i64; iter n]);
8    let acc: Accumulate<AdditiveOperation<i64>> = a.collect();
9    sc!(lr: [(usize, usize); iter q]);
10    for (l, r) in lr {
11        pp!(acc.fold(l..r));
12    }
13}

Trait Implementations§

Source§

impl<M> Debug for Accumulate<M>
where M: Monoid<T: Debug>,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<M> FromIterator<<M as Magma>::T> for Accumulate<M>
where M: Monoid,

Source§

fn from_iter<T>(iter: T) -> Self
where T: IntoIterator<Item = M::T>,

Creates a value from an iterator. Read more

Auto Trait Implementations§

§

impl<M> Freeze for Accumulate<M>
where Vec<<M as Magma>::T>: Freeze,

§

impl<M> RefUnwindSafe for Accumulate<M>
where Vec<<M as Magma>::T>: RefUnwindSafe,

§

impl<M> Send for Accumulate<M>
where Vec<<M as Magma>::T>: Send,

§

impl<M> Sync for Accumulate<M>
where Vec<<M as Magma>::T>: Sync,

§

impl<M> Unpin for Accumulate<M>
where Vec<<M as Magma>::T>: Unpin,

§

impl<M> UnsafeUnpin for Accumulate<M>
where Vec<<M as Magma>::T>: UnsafeUnpin,

§

impl<M> UnwindSafe for Accumulate<M>
where Vec<<M as Magma>::T>: 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.