Struct containers::collections::b_tree::BTree
[−]
[src]
pub struct BTree<K, T, B: Unsigned = U2, Rel: TotalOrderRelation<K> = Ord> { // some fields omitted }
A B-node has m
key-value pairs, and m+1
children if it is a stem, with the keys between
the children so each key is greater than all keys in its left subtree and less than all keys
in its right subtree.
A node other than the root has b-1 ≤ m ≤ 2b-1
, where b
is the branching parametre of the
tree; the root may have fewer.
Methods
impl<K, T, B: Unsigned, Rel: TotalOrderRelation<K>> BTree<K, T, B, Rel>
[src]
fn new() -> Option<Self>
fn size(&self) -> usize
Return number of elements.
fn find(&self, k: &K) -> Option<&T>
Find value with given key k
.
fn find_mut(&mut self, k: &K) -> Option<&mut T>
Find value with given key k
.
fn min(&self) -> Option<(&K, &T)>
Find value with minimum key.
Return None
if tree empty.
fn max(&self) -> Option<(&K, &T)>
Find value with maximum key.
Return None
if tree empty.
fn min_mut(&mut self) -> Option<(&K, &mut T)>
Find value with minimum key.
Return None
if tree empty.
fn max_mut(&mut self) -> Option<(&K, &mut T)>
Find value with maximum key.
Return None
if tree empty.
fn insert_with<F: FnOnce(Option<T>) -> T>(&mut self, k: K, f: F) -> Result<(), (K, T)>
Seek k
; if not found, insert f(None)
there; if found, modify the value there from x
to f(Some(x))
.
Failures
Returns Err
if allocation fails.
fn replace(&mut self, k: K, x: T) -> Result<Option<T>, (K, T)>
: now called insert
fn insert(&mut self, k: K, x: T) -> Result<Option<T>, (K, T)>
Insert x
at k
and return Some(x)
if there was already a value x
there.
Failures
Returns Err
if allocation fails.
fn delete(&mut self, k: &K) -> Option<(K, T)>
Seek k
; if found, delete it and value x
there and return Some((k, x))
.
fn fold_with_key<A, F: Fn(A, &K, &T) -> A>(&self, z0: A, f: F) -> A
: now called foldl_with_key
fn foldl_with_key<A, F: Fn(A, &K, &T) -> A>(&self, z0: A, f: F) -> A
Fold elements in forward order.
fn foldr_with_key<A, F: Fn(A, &K, &T) -> A>(&self, z0: A, f: F) -> A
Fold elements in backward order.