Trait outils::tree::bst::BinarySearchTree [] [src]

pub trait BinarySearchTree<K, V, Ix = DefaultIndexType> where
    K: KeyType,
    V: ValueType,
    Ix: IndexType
{ fn insert(&mut self, key: K, value: V) -> Option<V>;
fn remove(&mut self, key: &K) -> Option<V>;
fn contains_key(&self, key: &K) -> bool;
fn get(&self, key: &K) -> Option<&V>;
fn get_mut(&mut self, key: &K) -> Option<&mut V>;
fn index(&self, key: &K) -> Option<NodeIndex<Ix>>;
fn key(&self, node: NodeIndex<Ix>) -> Option<&K>; }

This trait defines the fundamental operations of a binary search tree.

Required Methods

Inserts a key-value pair into the tree. If the tree did not have this key present, None is returned. If the tree did have this key present, the value is updated, and the old value is returned. Note that in this situation, the key is left unchanged.

Removes a key from the tree if present, in this case returning the associated value.

Returns true if the map contains a value for the specified key.

Returns an immutable reference to the associated value of the specified key.

Returns a mutable reference to the associated value of the specified key.

Returns the index of the tree node holding the specified key.

Returns the key held by the tree node indexed by node.

Implementors