Struct intrusive_splay_tree::SplayTree [] [src]

pub struct SplayTree<'a, T> where
    T: IntrusiveNode<'a>,
    T::Elem: 'a, 
{ /* fields omitted */ }

An intrusive splay tree.

The tree is parameterized by some marker type T whose IntrusiveNode implementation defines:

  • the element type contained in this tree: T::Elem,
  • how to get the intrusive node for this tree within an element,
  • and how to get the container element from a given intrusive node for this tree.

Methods

impl<'a, T> SplayTree<'a, T> where
    T: 'a + IntrusiveNode<'a>, 
[src]

[src]

Is this tree empty?

[src]

Get a reference to the root element, if any exists.

[src]

Find an element in the tree.

This operation will splay the queried element to the root of the tree.

The key must be of a type that implements TreeOrd for this tree's T type. The element type T::Elem must always implement TreeOrd<T>, so you can search the tree by element. You can also implement TreeOrd<T> for additional key types. This allows you to search the tree without constructing a full element.

[src]

Insert a new element into this tree.

Returns true if the element was inserted into the tree.

Returns false if there was already an element in the tree for which TreeOrd returned Ordering::Equal. In this case, the extant element is left in the tree, and elem is not inserted.

This operation will splay the inserted element to the root of the tree.

It is a logic error to insert an element that is already inserted in a T tree.

Panics

If debug_assertions are enabled, then this function may panic if elem is already in a T tree. If debug_assertions are not defined, the behavior is safe, but unspecified.

[src]

Find and remove an element from the tree.

If a matching element is found and removed, then Some(removed_element) is returned. Otherwise None is returned.

The key must be of a type that implements TreeOrd for this tree's T type. The element type T::Elem must always implement TreeOrd<T>, so you can remove an element directly. You can also implement TreeOrd<T> for additional key types. This allows you to search the tree without constructing a full element, and remove the element that matches the given key, if any.

[src]

Walk the tree in order.

The C type controls whether iteration should continue, or break and return a C::Result value. You can use () as C, and that always continues iteration. Using Result<(), E> as C allows you to halt iteration on error, and propagate the error value. Using Option<T> as C allows you to search for some value, halt iteration when its found, and return it.

Trait Implementations

impl<'a, T> Default for SplayTree<'a, T> where
    T: 'a + IntrusiveNode<'a>,
    T::Elem: 'a, 
[src]

[src]

Returns the "default value" for a type. Read more

impl<'a, T> Debug for SplayTree<'a, T> where
    T: 'a + IntrusiveNode<'a>,
    T::Elem: 'a + Debug
[src]

[src]

Formats the value using the given formatter. Read more

impl<'a, T> Extend<&'a T::Elem> for SplayTree<'a, T> where
    T: 'a + IntrusiveNode<'a>, 
[src]

[src]

Extends a collection with the contents of an iterator. Read more

impl<'a, T> FromIterator<&'a T::Elem> for SplayTree<'a, T> where
    T: 'a + IntrusiveNode<'a>,
    T::Elem: Debug
[src]

[src]

Creates a value from an iterator. Read more

Auto Trait Implementations

impl<'a, T> !Send for SplayTree<'a, T>

impl<'a, T> !Sync for SplayTree<'a, T>