Skip to main content

LazyMapElement

Struct LazyMapElement 

Source
pub struct LazyMapElement<L>
where L: LazyMapMonoid,
{ pub key: L::Key, pub agg: L::Agg, pub act: L::Act, }

Fields§

§key: L::Key§agg: L::Agg§act: L::Act

Implementations§

Source§

impl<L> LazyMapElement<L>
where L: LazyMapMonoid,

Source

pub fn from_key(key: L::Key) -> Self

Examples found in repository?
crates/competitive/src/tree/link_cut_tree.rs (line 458)
456    fn new(value: Self::Value) -> Self::Data {
457        Self::Data {
458            value: LazyMapElement::from_key(value),
459        }
460    }
More examples
Hide additional examples
crates/competitive/src/data_structure/implicit_splay_tree.rs (line 240)
237    fn node(&mut self, key: T::Key) -> ImplicitSplayTreeRoot<T> {
238        BstRoot::from_data(
239            ImplicitSplayTreeData {
240                value: LazyMapElement::from_key(key),
241                size: 1,
242                rev: false,
243            },
244            self.allocator.deref_mut(),
245        )
246    }
crates/competitive/src/data_structure/implicit_treap.rs (line 288)
284    fn node(&mut self, key: T::Key) -> ImplicitTreapRoot<T> {
285        BstRoot::from_data(
286            ImplicitTreapData {
287                priority: self.rng.rand64(),
288                value: LazyMapElement::from_key(key),
289                size: 1,
290                rev: false,
291            },
292            self.allocator.deref_mut(),
293        )
294    }
crates/competitive/src/data_structure/treap.rs (line 372)
366    pub fn insert(&mut self, key: M::Key, value: L::Key) -> BstNodeId<TreapSpec<M, L>> {
367        let (left, right) =
368            TreapSpec::split(self.root.take(), SeekByKey::new(&key), EqualSide::Right);
369        let data = TreapData {
370            priority: self.rng.rand64(),
371            key: MonoidActElement::from_key(key),
372            value: LazyMapElement::from_key(value),
373        };
374        let node = BstRoot::from_data(data, self.allocator.deref_mut());
375        let node_id = self.node_id_manager.register(&node);
376        self.root = TreapSpec::merge(TreapSpec::merge(left, Some(node)), right);
377        node_id
378    }
Source

pub fn update_act<Spec>(node: BstDataMutRef<'_, Spec>, act: &L::Act)
where Spec: BstSpec<Data: BstDataAccess<LazyMap, Value = Self>>,

Examples found in repository?
crates/competitive/src/data_structure/treap.rs (line 486)
484    pub fn update_value(&mut self, act: L::Act) {
485        if let Some(node) = self.split3.mid_datamut() {
486            LazyMapElement::<L>::update_act(node, &act);
487        }
488    }
More examples
Hide additional examples
crates/competitive/src/data_structure/binary_search_tree/data.rs (line 170)
161    pub fn top_down<Spec>(mut node: BstDataMutRef<'_, Spec>)
162    where
163        Spec: BstSpec<Data: BstDataAccess<marker::LazyMap, Value = Self>>,
164    {
165        if L::is_act_unit(&node.reborrow().into_data().bst_data().act) {
166            return;
167        }
168        let act = replace(&mut node.data_mut().bst_data_mut().act, L::act_unit());
169        if let Ok(left) = node.reborrow_datamut().left().descend() {
170            Self::update_act(left, &act);
171        }
172        if let Ok(right) = node.reborrow_datamut().right().descend() {
173            Self::update_act(right, &act);
174        }
175    }
Source

pub fn top_down<Spec>(node: BstDataMutRef<'_, Spec>)
where Spec: BstSpec<Data: BstDataAccess<LazyMap, Value = Self>>,

Examples found in repository?
crates/competitive/src/data_structure/treap.rs (line 110)
108    fn top_down(mut node: BstDataMutRef<'_, Self>) {
109        MonoidActElement::<M>::top_down(node.reborrow_datamut());
110        LazyMapElement::<L>::top_down(node.reborrow_datamut());
111    }
More examples
Hide additional examples
crates/competitive/src/data_structure/binary_search_tree/data.rs (line 156)
143    pub fn update_act<Spec>(mut node: BstDataMutRef<'_, Spec>, act: &L::Act)
144    where
145        Spec: BstSpec<Data: BstDataAccess<marker::LazyMap, Value = Self>>,
146    {
147        if L::is_act_unit(act) {
148            return;
149        }
150        L::act_operate_assign(&mut node.data_mut().bst_data_mut().act, act);
151        node.data_mut().bst_data_mut().key =
152            L::act_key(&node.reborrow().into_data().bst_data().key, act);
153        if let Some(nxlazy) = L::act_agg(&node.reborrow().into_data().bst_data().agg, act) {
154            node.data_mut().bst_data_mut().agg = nxlazy;
155        } else {
156            Self::top_down(node.reborrow_datamut());
157            Self::bottom_up(node.reborrow_datamut());
158        }
159    }
Source

pub fn bottom_up<Spec>(node: BstDataMutRef<'_, Spec>)
where Spec: BstSpec<Data: BstDataAccess<LazyMap, Value = Self>>,

Examples found in repository?
crates/competitive/src/data_structure/treap.rs (line 114)
113    fn bottom_up(mut node: BstDataMutRef<'_, Self>) {
114        LazyMapElement::<L>::bottom_up(node.reborrow_datamut());
115    }
More examples
Hide additional examples
crates/competitive/src/data_structure/binary_search_tree/data.rs (line 157)
143    pub fn update_act<Spec>(mut node: BstDataMutRef<'_, Spec>, act: &L::Act)
144    where
145        Spec: BstSpec<Data: BstDataAccess<marker::LazyMap, Value = Self>>,
146    {
147        if L::is_act_unit(act) {
148            return;
149        }
150        L::act_operate_assign(&mut node.data_mut().bst_data_mut().act, act);
151        node.data_mut().bst_data_mut().key =
152            L::act_key(&node.reborrow().into_data().bst_data().key, act);
153        if let Some(nxlazy) = L::act_agg(&node.reborrow().into_data().bst_data().agg, act) {
154            node.data_mut().bst_data_mut().agg = nxlazy;
155        } else {
156            Self::top_down(node.reborrow_datamut());
157            Self::bottom_up(node.reborrow_datamut());
158        }
159    }

Trait Implementations§

Source§

impl<L> Debug for LazyMapElement<L>
where L: LazyMapMonoid<Key: Debug, Agg: Debug, Act: Debug>,

Source§

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

Formats the value using the given formatter. Read more

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> 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.