Skip to main content

RangeSumRangeChminChmaxAdd

Struct RangeSumRangeChminChmaxAdd 

Source
pub struct RangeSumRangeChminChmaxAdd<T> {
    min: T,
    max: T,
    min2: T,
    max2: T,
    pub sum: T,
    size: T,
    n_min: T,
    n_max: T,
}

Fields§

§min: T§max: T§min2: T§max2: T§sum: T§size: T§n_min: T§n_max: T

Implementations§

Source§

impl<T> RangeSumRangeChminChmaxAdd<T>
where T: Copy + Zero + One + Ord + Bounded + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + PartialEq,

Source

pub fn single(key: T, size: T) -> Self

Examples found in repository?
crates/competitive/src/algebra/lazy_map.rs (line 550)
549    fn single_agg(&key: &Self::Key) -> Self::Agg {
550        Self::single(key, T::one())
551    }
552    fn act_agg(x: &Self::Agg, a: &Self::Act) -> Option<Self::Agg> {
553        Some(if Self::is_act_unit(a) {
554            x.clone()
555        } else if x.size.is_zero() {
556            Self::unit()
557        } else if x.min == x.max || a.lb == a.ub || a.lb >= x.max || a.ub <= x.min {
558            Self::single(x.min.max(a.lb).min(a.ub) + a.bias, x.size)
559        } else if x.min2 == x.max {
560            let mut x = x.clone();
561            let min = x.min.max(a.lb) + a.bias;
562            let max = x.max.min(a.ub) + a.bias;
563            x.min = min;
564            x.max2 = min;
565            x.max = max;
566            x.min2 = max;
567            x.sum = min * x.n_min + max * x.n_max;
568            x
569        } else if a.lb < x.min2 && x.max2 < a.ub {
570            let mut x = x.clone();
571            let min = x.min.max(a.lb);
572            let max = x.max.min(a.ub);
573            x.sum = x.sum + (min - x.min) * x.n_min + (max - x.max) * x.n_max + a.bias * x.size;
574            x.min = min + a.bias;
575            x.max = max + a.bias;
576            x.min2 = x.min2 + a.bias;
577            x.max2 = x.max2 + a.bias;
578            x
579        } else {
580            return None;
581        })
582    }

Trait Implementations§

Source§

impl<T> Associative for RangeSumRangeChminChmaxAdd<T>
where T: Copy + Zero + One + Ord + Bounded + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + PartialEq,

Source§

impl<T: Clone> Clone for RangeSumRangeChminChmaxAdd<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for RangeSumRangeChminChmaxAdd<T>

Source§

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

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

impl<T: Eq> Eq for RangeSumRangeChminChmaxAdd<T>

Source§

impl<T> LazyMapMonoid for RangeSumRangeChminChmaxAdd<T>
where T: Copy + Zero + One + Ord + Bounded + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + PartialEq,

Source§

type Key = T

Source§

type Agg = RangeSumRangeChminChmaxAdd<T>

Source§

type Act = RangeChminChmaxAdd<T>

Source§

type AggMonoid = RangeSumRangeChminChmaxAdd<T>

Source§

type ActMonoid = RangeChminChmaxAdd<T>

Source§

type KeyAct = RangeChminChmaxAdd<T>

Source§

fn single_agg(key: &Self::Key) -> Self::Agg

Source§

fn act_agg(x: &Self::Agg, a: &Self::Act) -> Option<Self::Agg>

Source§

fn toggle(_x: &mut Self::Agg)

Source§

fn is_act_unit(act: &Self::Act) -> bool

Source§

fn act_key(x: &Self::Key, a: &Self::Act) -> Self::Key

Source§

fn agg_unit() -> Self::Agg

Source§

fn act_unit() -> Self::Act

Source§

fn agg_operate(x: &Self::Agg, y: &Self::Agg) -> Self::Agg

Source§

fn act_operate(x: &Self::Act, y: &Self::Act) -> Self::Act

Source§

fn agg_operate_assign(x: &mut Self::Agg, y: &Self::Agg)

Source§

fn act_operate_assign(x: &mut Self::Act, y: &Self::Act)

Source§

impl<T> Magma for RangeSumRangeChminChmaxAdd<T>
where T: Copy + Zero + One + Ord + Bounded + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + PartialEq,

Source§

type T = RangeSumRangeChminChmaxAdd<T>

type of operands: $T$
Source§

fn operate(x: &Self::T, y: &Self::T) -> Self::T

binary operaion: $\circ$
Source§

fn reverse_operate(x: &Self::T, y: &Self::T) -> Self::T

Source§

fn operate_assign(x: &mut Self::T, y: &Self::T)

Source§

impl<T: PartialEq> PartialEq for RangeSumRangeChminChmaxAdd<T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T: PartialEq> StructuralPartialEq for RangeSumRangeChminChmaxAdd<T>

Source§

impl<T> Unital for RangeSumRangeChminChmaxAdd<T>
where T: Copy + Zero + One + Ord + Bounded + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + PartialEq,

Source§

fn unit() -> Self::T

identity element: $e$
Source§

fn is_unit(x: &Self::T) -> bool
where Self::T: PartialEq,

Source§

fn set_unit(x: &mut Self::T)

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<M> Monoid for M
where M: SemiGroup + Unital,

Source§

fn pow<E>(x: Self::T, exp: E) -> Self::T
where E: ExpBits,

binary exponentiation: $x^n = x\circ\ddots\circ x$
Source§

fn fold<I>(iter: I) -> Self::T
where I: IntoIterator<Item = Self::T>,

Source§

impl<S> SemiGroup for S
where S: Magma + Associative,

Source§

impl<T> ToArrayVecScalar for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.