Struct Tree

Source
pub struct Tree<P: Prefixable, D> { /* private fields */ }
Expand description

Tree struct.

Implementations§

Source§

impl<P: Prefixable, D> Tree<P, D>

Tree impl.

Source

pub fn new() -> Tree<P, D>

Constructor.

Source

pub fn top(&self) -> Option<Rc<Node<P, D>>>

Return top node.

Source

pub fn count(&self) -> usize

Return count with data.

Source

pub fn get_node(&mut self, prefix: &P) -> NodeIterator<P, D>

Get node with given prefix, create one if it doesn’t exist.

Source

pub fn get_node_ctor<F>( &mut self, prefix: &P, ctor: Option<F>, ) -> NodeIterator<P, D>
where F: Fn() -> D,

Get node with given prefix, create one if it doesn’t exist. And also construct ‘D’ with given constructor.

Source

pub fn insert(&mut self, prefix: &P, data: D) -> Option<D>

Insert data with given prefix, and return:

  • Some(data) if data already exist with the prefix.
  • None if successfully inserted the data.
Source

pub fn update(&mut self, prefix: &P, data: D) -> Option<D>

Update data with given prefix, and return:

  • old data if data exists and successfully replace.
  • None if data does not exist, and replace does not occur.
Source

pub fn upsert(&mut self, prefix: &P, data: D) -> Option<D>

Insert if data does not exist, or Update, and return:

  • old data if data exists and successfully replace.
  • None if data does not exist.
Source

pub fn delete(&mut self, prefix: &P) -> Option<D>

Delete data with the prefix if data exist, and return:

  • old data if data exists and successfully delete.
  • None if data does not exist.
Source

pub fn lookup_exact(&self, prefix: &P) -> NodeIterator<P, D>

Perform exact match lookup.

Source

pub fn lookup(&self, prefix: &P) -> NodeIterator<P, D>

Perform longest match lookup.

Source

pub fn erase(&mut self, it: NodeIterator<P, D>) -> NodeIterator<P, D>

Erase a node from tree, and return iterator for next node.

Source

pub fn node_iter(&self) -> NodeIterator<P, D>

Return node iterator.

Trait Implementations§

Source§

impl<P: Prefixable, D> IntoIterator for &Tree<P, D>

Tree IntoIterator.

Source§

type Item = Rc<Node<P, D>>

The type of the elements being iterated over.
Source§

type IntoIter = DataIterator<P, D>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<P, D> Freeze for Tree<P, D>

§

impl<P, D> !RefUnwindSafe for Tree<P, D>

§

impl<P, D> !Send for Tree<P, D>

§

impl<P, D> !Sync for Tree<P, D>

§

impl<P, D> Unpin for Tree<P, D>

§

impl<P, D> !UnwindSafe for Tree<P, D>

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.