[−][src]Struct intrusive_splay_tree::SplayTree
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.
Implementations
impl<'a, T> SplayTree<'a, T> where
T: 'a + IntrusiveNode<'a>,
[src]
T: 'a + IntrusiveNode<'a>,
pub fn is_empty(&self) -> bool
[src]
Is this tree empty?
pub fn root(&self) -> Option<&'a T::Elem>
[src]
Get a reference to the root element, if any exists.
pub fn find<K: ?Sized>(&mut self, key: &K) -> Option<&'a T::Elem> where
K: TreeOrd<'a, T>,
[src]
K: TreeOrd<'a, T>,
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.
pub fn insert(&mut self, elem: &'a T::Elem) -> bool
[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.
pub fn remove<K: ?Sized>(&mut self, key: &K) -> Option<&'a T::Elem> where
K: TreeOrd<'a, T>,
[src]
K: TreeOrd<'a, T>,
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.
pub fn walk<F, C>(&self, f: F) -> Option<C::Result> where
F: FnMut(&'a T::Elem) -> C,
C: WalkControl,
[src]
F: FnMut(&'a T::Elem) -> C,
C: WalkControl,
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> Debug for SplayTree<'a, T> where
T: 'a + IntrusiveNode<'a>,
T::Elem: 'a + Debug,
[src]
T: 'a + IntrusiveNode<'a>,
T::Elem: 'a + Debug,
impl<'a, T> Default for SplayTree<'a, T> where
T: 'a + IntrusiveNode<'a>,
T::Elem: 'a,
[src]
T: 'a + IntrusiveNode<'a>,
T::Elem: 'a,
impl<'a, T> Extend<&'a <T as IntrusiveNode<'a>>::Elem> for SplayTree<'a, T> where
T: 'a + IntrusiveNode<'a>,
[src]
T: 'a + IntrusiveNode<'a>,
fn extend<I: IntoIterator<Item = &'a T::Elem>>(&mut self, iter: I)
[src]
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl<'a, T> FromIterator<&'a <T as IntrusiveNode<'a>>::Elem> for SplayTree<'a, T> where
T: 'a + IntrusiveNode<'a>,
T::Elem: Debug,
[src]
T: 'a + IntrusiveNode<'a>,
T::Elem: Debug,
fn from_iter<I: IntoIterator<Item = &'a T::Elem>>(iter: I) -> Self
[src]
Auto Trait Implementations
impl<'a, T> !Send for SplayTree<'a, T>
impl<'a, T> !Sync for SplayTree<'a, T>
impl<'a, T> Unpin for SplayTree<'a, T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,