Trait BinarySearchTree

Source
pub trait BinarySearchTree<K, V, Ix = DefaultIndexType>
where K: KeyType, V: ValueType, Ix: IndexType,
{ // Required methods fn insert_pos(&self, key: K) -> Option<(NodeIndex, Ordering)>; 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>; }
Expand description

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

Required Methods§

Source

fn insert_pos(&self, key: K) -> Option<(NodeIndex, Ordering)>

Returns the insertion point for a given key. None is returned, if the tree is empty, otherwise an index to a node is returned together with the result of the comparison against its key.

Source

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.

Source

fn remove(&mut self, key: K) -> Option<V>

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

Source

fn contains_key(&self, key: K) -> bool

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

Source

fn get(&self, key: K) -> Option<&V>

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

Source

fn get_mut(&mut self, key: K) -> Option<&mut V>

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

Source

fn index(&self, key: K) -> Option<NodeIndex<Ix>>

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

Source

fn key(&self, node: NodeIndex<Ix>) -> Option<&K>

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

Implementors§

Source§

impl<K, V> BinarySearchTree<K, V> for AaTree<K, V>
where K: KeyType, V: ValueType,

Source§

impl<K, V, W> BinarySearchTree<K, V> for WeightedAaTree<K, V, W>
where K: KeyType, V: ValueType, W: WeightType,