bitstring_trees::tree

Struct Walk

source
pub struct Walk<'r, TP: TreeProperties, D = (), A = ()> { /* private fields */ }
Expand description

Walk tree

Some algorithms need to remember how they reached the current node via WalkedDirection as D.

When walking manually it might be useful to be able to store additional data via A; look for functions with the suffix _with.

Implementations§

source§

impl<'r, TP: TreeProperties, D, A> Walk<'r, TP, D, A>

source

pub fn up(&mut self) -> Option<D>

Walk up to parent node or tree if not at tree

source

pub fn up_with(&mut self) -> Option<(D, A)>

Walk up to parent node or tree if not at tree

source

pub fn current(&self) -> NodeOrTree<Option<&'r Node<TP>>, &'r Node<TP>>

Current node or tree

source§

impl<'r, TP: TreeProperties, D, A> Walk<'r, TP, D, A>

source

pub fn down_root_with(&mut self, add: A) -> bool

Walk down from tree to root node (if present)

source

pub fn down_left_with(&mut self, add: A) -> bool

Walk down to left node if present and not currently at tree

source

pub fn down_right_with(&mut self, add: A) -> bool

Walk down to right node if present and not currently at tree

source

pub fn down_with(&mut self, side: bool, add: A) -> bool

Walk down to specified node if present and not currently at tree

false picks left and true picks right.

source§

impl<'r, TP: TreeProperties, D> Walk<'r, TP, D, ()>

source

pub fn down_root(&mut self) -> bool

Walk down from tree to root node (if at tree and not empty)

source

pub fn down_left(&mut self) -> bool

Walk down to left node if present and not currently at tree

source

pub fn down_right(&mut self) -> bool

Walk down to right node if present and not currently at tree

source

pub fn down(&mut self, side: bool) -> bool

Walk down to specified node if present and not currently at tree

false picks left and true picks right.

source§

impl<'r, TP: TreeProperties, D> Walk<'r, TP, D>

source

pub fn goto_insert(&mut self, key: &TP::Key) -> Option<InsertPosition>

Walk to node where we’d have to insert key at

This can either be:

  • root if and only if the tree is empty
  • node with exactly matching key
  • node where the key is between the parent node (possibly root) and the node
    • to insert the key here we might have to create a new inner node and move the existing node down
source§

impl<'r, TP: TreeProperties> Walk<'r, TP, WalkedDirection>

source

pub fn next_pre_order(&mut self) -> Option<&'r Node<TP>>

Tree traversal: depth-first pre-order

source

pub fn next_in_order(&mut self) -> Option<&'r Node<TP>>

Tree traversal: depth-first in-order

source

pub fn next_leaf(&mut self) -> Option<&'r Node<TP>>

Tree traversal: depth-first in-order leaf nodes only

source

pub fn next_post_order(&mut self) -> Option<&'r Node<TP>>

Tree traversal: depth-first post-order

Auto Trait Implementations§

§

impl<'r, TP, D, A> Freeze for Walk<'r, TP, D, A>

§

impl<'r, TP, D, A> RefUnwindSafe for Walk<'r, TP, D, A>

§

impl<'r, TP, D, A> Send for Walk<'r, TP, D, A>
where <TP as TreeProperties>::Key: Sync, <TP as TreeProperties>::Value: Sync, <TP as TreeProperties>::LeafValue: Sync, D: Send, A: Send,

§

impl<'r, TP, D, A> Sync for Walk<'r, TP, D, A>
where <TP as TreeProperties>::Key: Sync, <TP as TreeProperties>::Value: Sync, <TP as TreeProperties>::LeafValue: Sync, D: Sync, A: Sync,

§

impl<'r, TP, D, A> Unpin for Walk<'r, TP, D, A>
where D: Unpin, A: Unpin,

§

impl<'r, TP, D, A> UnwindSafe for Walk<'r, TP, D, A>

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