Skip to main content

Node

Struct Node 

Source
pub struct Node<E: TreapEntry> { /* private fields */ }
Expand description

Node in the Treap.

It can be dereferenced into a shared reference to the TreapEntry. You can also use Node::neighbors to get an iterator over the neighbors of this node.

Implementations§

Source§

impl<E: TreapEntry> Node<E>

Source

pub fn neighbors<'treap>( &'treap self, filter: &'treap E::FilteringKey, skip_right: bool, ) -> impl Iterator<Item = &'treap Self>

Returns an iterator over nodes reachable from self whose filtering_key() >= filter.

Traversal visits both subtree descendants and ancestors, pruning branches where the subtree’s max_filter < filter.

skip_right skips the right subtree on the first step, useful when the caller has already consumed the greatest node (e.g., after Treap::peek_max_with_filter).

§Example
use orengine_utils::treap::{BaseTreapEntry, Treap};

let mut treap = Treap::<BaseTreapEntry<usize, usize, ()>>::new();

for i in 1..=5 {
    treap.set(BaseTreapEntry::new(i, i, ()));
}

let node = treap.peek_max_with_filter(&3).unwrap();

let keys: Vec<_> = node.neighbors(&3, true) // `true` because we already know the greatest entry with `FilteringKey` >= 3
    .map(|n| n.sorting_key)
    .collect();

assert_eq!(keys, vec![5, 4, 3]);

Trait Implementations§

Source§

impl<E: TreapEntry> Deref for Node<E>

Source§

type Target = E

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<E> !Send for Node<E>

§

impl<E> !Sync for Node<E>

§

impl<E> Freeze for Node<E>
where E: Freeze, <E as TreapEntry>::FilteringKey: Freeze,

§

impl<E> RefUnwindSafe for Node<E>

§

impl<E> Unpin for Node<E>
where E: Unpin, <E as TreapEntry>::FilteringKey: Unpin,

§

impl<E> UnsafeUnpin for Node<E>

§

impl<E> UnwindSafe for Node<E>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.