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
fn insert(&mut self, key: K, value: V) -> Option<V>
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.
fn remove(&mut self, key: &K) -> Option<V>
Removes a key
from the tree if present, in this case returning the associated value.
fn contains_key(&self, key: &K) -> bool
Returns true
if the map contains a value for the specified key
.
fn get(&self, key: &K) -> Option<&V>
Returns an immutable reference to the associated value of the specified key
.
fn get_mut(&mut self, key: &K) -> Option<&mut V>
Returns a mutable reference to the associated value of the specified key
.
fn index(&self, key: &K) -> Option<NodeIndex<Ix>>
Returns the index of the tree node holding the specified key
.
fn key(&self, node: NodeIndex<Ix>) -> Option<&K>
Returns the key held by the tree node indexed by node
.
Implementors
impl<K, V> BinarySearchTree<K, V> for AaTree<K, V> where
K: KeyType,
V: ValueType,impl<K, V, W> BinarySearchTree<K, V> for WeightedAaTree<K, V, W> where
K: KeyType,
V: ValueType,
W: WeightType,