MonoidAct

Trait MonoidAct 

Source
pub trait MonoidAct {
    type Key;
    type Act: Clone;
    type ActMonoid: Monoid<T = Self::Act>;

    // Required method
    fn act(x: &Self::Key, a: &Self::Act) -> Self::Key;

    // Provided methods
    fn act_assign(x: &mut Self::Key, a: &Self::Act) { ... }
    fn unit() -> Self::Act { ... }
    fn operate(x: &Self::Act, y: &Self::Act) -> Self::Act { ... }
    fn operate_assign(x: &mut Self::Act, y: &Self::Act) { ... }
}

Required Associated Types§

Required Methods§

Source

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

Provided Methods§

Source

fn act_assign(x: &mut Self::Key, a: &Self::Act)

Examples found in repository?
crates/competitive/src/data_structure/pairing_heap.rs (line 35)
34    fn apply(&mut self, act: &A::Act) {
35        A::act_assign(&mut self.value, act);
36        A::operate_assign(&mut self.lazy, act);
37    }
More examples
Hide additional examples
crates/competitive/src/data_structure/binary_search_tree/data.rs (line 91)
86    pub fn update_act<Spec>(mut node: BstDataMutRef<'_, Spec>, act: &M::Act)
87    where
88        Spec: BstSpec<Data: BstDataAccess<marker::MonoidAct, Value = Self>>,
89    {
90        M::operate_assign(&mut node.data_mut().bst_data_mut().act, act);
91        M::act_assign(&mut node.data_mut().bst_data_mut().key, act);
92    }
Source

fn unit() -> Self::Act

Examples found in repository?
crates/competitive/src/data_structure/binary_search_tree/data.rs (line 82)
79    pub fn from_key(key: M::Key) -> Self {
80        Self {
81            key,
82            act: M::unit(),
83        }
84    }
85
86    pub fn update_act<Spec>(mut node: BstDataMutRef<'_, Spec>, act: &M::Act)
87    where
88        Spec: BstSpec<Data: BstDataAccess<marker::MonoidAct, Value = Self>>,
89    {
90        M::operate_assign(&mut node.data_mut().bst_data_mut().act, act);
91        M::act_assign(&mut node.data_mut().bst_data_mut().key, act);
92    }
93
94    pub fn top_down<Spec>(mut node: BstDataMutRef<'_, Spec>)
95    where
96        Spec: BstSpec<Data: BstDataAccess<marker::MonoidAct, Value = Self>>,
97    {
98        let act = replace(&mut node.data_mut().bst_data_mut().act, M::unit());
99        if let Ok(left) = node.reborrow_datamut().left().descend() {
100            Self::update_act(left, &act);
101        }
102        if let Ok(right) = node.reborrow_datamut().right().descend() {
103            Self::update_act(right, &act);
104        }
105    }
More examples
Hide additional examples
crates/competitive/src/data_structure/pairing_heap.rs (line 30)
25    fn new(value: T) -> Self {
26        Self {
27            value,
28            first_child: None,
29            next_sibling: None,
30            lazy: A::unit(),
31        }
32    }
33
34    fn apply(&mut self, act: &A::Act) {
35        A::act_assign(&mut self.value, act);
36        A::operate_assign(&mut self.lazy, act);
37    }
38
39    fn propagate(&mut self) {
40        if !<A::ActMonoid as Unital>::is_unit(&self.lazy) {
41            let act = replace(&mut self.lazy, A::unit());
42            if let Some(node) = self.first_child.as_mut() {
43                node.apply(&act);
44            }
45            if let Some(node) = self.next_sibling.as_mut() {
46                node.apply(&act);
47            }
48        }
49    }
Source

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

Source

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

Examples found in repository?
crates/competitive/src/data_structure/pairing_heap.rs (line 36)
34    fn apply(&mut self, act: &A::Act) {
35        A::act_assign(&mut self.value, act);
36        A::operate_assign(&mut self.lazy, act);
37    }
More examples
Hide additional examples
crates/competitive/src/data_structure/binary_search_tree/data.rs (line 90)
86    pub fn update_act<Spec>(mut node: BstDataMutRef<'_, Spec>, act: &M::Act)
87    where
88        Spec: BstSpec<Data: BstDataAccess<marker::MonoidAct, Value = Self>>,
89    {
90        M::operate_assign(&mut node.data_mut().bst_data_mut().act, act);
91        M::act_assign(&mut node.data_mut().bst_data_mut().key, act);
92    }

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<M> MonoidAct for FlattenAct<M>
where M: Monoid,

Source§

type Key = <M as Magma>::T

Source§

type Act = <M as Magma>::T

Source§

type ActMonoid = M

Source§

impl<T> MonoidAct for EmptyAct<T>
where T: Clone,

Source§

impl<T> MonoidAct for LinearAct<T>
where T: Clone + Zero + One + Add<Output = T> + Mul<Output = T>,

Source§

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

Source§

impl<T> MonoidAct for UpdateAct<T>
where T: Clone,