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>
impl<E: TreapEntry> Node<E>
Sourcepub fn neighbors<'treap>(
&'treap self,
filter: &'treap E::FilteringKey,
skip_right: bool,
) -> impl Iterator<Item = &'treap Self>
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§
Auto Trait Implementations§
impl<E> !Send for Node<E>
impl<E> !Sync for Node<E>
impl<E> Freeze for Node<E>
impl<E> RefUnwindSafe for Node<E>
impl<E> Unpin for Node<E>
impl<E> UnsafeUnpin for Node<E>
impl<E> UnwindSafe for Node<E>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more