Skip to main content

EqualSide

Enum EqualSide 

Source
pub enum EqualSide {
    Left,
    Right,
}

Variants§

§

Left

§

Right

Implementations§

Source§

impl EqualSide

Source

pub fn goes_left(self, ordering: Ordering) -> bool

Examples found in repository?
crates/competitive/src/data_structure/splay_operations.rs (line 428)
415pub fn split<Spec, Data, Seeker>(
416    root: Option<BstRoot<Spec>>,
417    seeker: Seeker,
418    equal_side: EqualSide,
419) -> (Option<BstRoot<Spec>>, Option<BstRoot<Spec>>)
420where
421    Spec: BstSpec<Data = Data, Parent = WithNoParent<Data>>,
422    Seeker: BstSeeker<Spec = Spec>,
423{
424    let Some(root) = root else {
425        return (None, None);
426    };
427    let (ordering, mut root) = splay(root, seeker);
428    if equal_side.goes_left(ordering) {
429        let right = unsafe { root.borrow_mut().right_mut().take() };
430        Spec::bottom_up(root.borrow_datamut());
431        (Some(root), right)
432    } else {
433        let left = unsafe { root.borrow_mut().left_mut().take() };
434        Spec::bottom_up(root.borrow_datamut());
435        (left, Some(root))
436    }
437}
More examples
Hide additional examples
crates/competitive/src/data_structure/treap.rs (line 156)
144    fn split<Seeker>(
145        node: Option<TreapRoot<M, L>>,
146        mut seeker: Seeker,
147        equal_side: EqualSide,
148    ) -> (Option<TreapRoot<M, L>>, Option<TreapRoot<M, L>>)
149    where
150        Seeker: BstSeeker<Spec = Self>,
151    {
152        match node {
153            None => (None, None),
154            Some(mut node) => {
155                Self::top_down(node.borrow_datamut());
156                if equal_side.goes_left(seeker.bst_seek(node.reborrow())) {
157                    unsafe {
158                        let right = node.borrow_mut().right().take();
159                        let (l, r) = Self::split(right, seeker, equal_side);
160                        if let Some(l) = l {
161                            node.borrow_mut().right().set(l);
162                        }
163                        Self::bottom_up(node.borrow_datamut());
164                        (Some(node), r)
165                    }
166                } else {
167                    unsafe {
168                        let left = node.borrow_mut().left().take();
169                        let (l, r) = Self::split(left, seeker, equal_side);
170                        if let Some(r) = r {
171                            node.borrow_mut().left().set(r);
172                        }
173                        Self::bottom_up(node.borrow_datamut());
174                        (l, Some(node))
175                    }
176                }
177            }
178        }
179    }
crates/competitive/src/data_structure/implicit_treap.rs (line 191)
179    fn split<Seeker>(
180        node: Option<ImplicitTreapRoot<T>>,
181        mut seeker: Seeker,
182        equal_side: EqualSide,
183    ) -> (Option<ImplicitTreapRoot<T>>, Option<ImplicitTreapRoot<T>>)
184    where
185        Seeker: BstSeeker<Spec = Self>,
186    {
187        match node {
188            None => (None, None),
189            Some(mut node) => {
190                Self::top_down(node.borrow_datamut());
191                if equal_side.goes_left(seeker.bst_seek(node.reborrow())) {
192                    unsafe {
193                        let right = node.borrow_mut().right().take();
194                        let (l, r) = Self::split(right, seeker, equal_side);
195                        if let Some(l) = l {
196                            node.borrow_mut().right().set(l);
197                        }
198                        Self::bottom_up(node.borrow_datamut());
199                        (Some(node), r)
200                    }
201                } else {
202                    unsafe {
203                        let left = node.borrow_mut().left().take();
204                        let (l, r) = Self::split(left, seeker, equal_side);
205                        if let Some(r) = r {
206                            node.borrow_mut().left().set(r);
207                        }
208                        Self::bottom_up(node.borrow_datamut());
209                        (l, Some(node))
210                    }
211                }
212            }
213        }
214    }

Trait Implementations§

Source§

impl Clone for EqualSide

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 Copy for EqualSide

Source§

impl Debug for EqualSide

Source§

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

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

impl Eq for EqualSide

Source§

impl PartialEq for EqualSide

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 StructuralPartialEq for EqualSide

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