Struct avltree::SearchTree

source ·
pub struct SearchTree<T: PartialEq + PartialOrd> { /* private fields */ }
Expand description

A simple AVL tree.

Implementations

Creates an empty search tree.

Example
use avltree::SearchTree;
let tree: SearchTree<String> = SearchTree::new();
assert!(tree.is_empty());

Test if this tree is empty.

Example
use avltree::SearchTree;
let mut tree: SearchTree<String> = SearchTree::new();
assert!(tree.is_empty());
tree.insert(String::from("foo"));
assert!(!tree.is_empty());

Test if this contains a given value.

Example
use avltree::SearchTree;
let mut tree: SearchTree<String> = SearchTree::new();
tree.insert(String::from("hello"));
tree.insert(String::from("world!"));
assert!(tree.contains(&String::from("hello")));
assert!(!tree.contains(&String::from("cruel")));

Add the specified value to this tree.

Example
use avltree::SearchTree;
let mut tree: SearchTree<String> = SearchTree::new();
tree.insert(String::from("hello"));
tree.insert(String::from("world!"));
assert!(tree.contains(&String::from("hello")));
assert!(tree.contains(&String::from("world!")));

Return an iterator over the values in this tree.

Example
use avltree::SearchTree;
let mut tree: SearchTree<u64> = SearchTree::new();
tree.insert(5);
tree.insert(2);
tree.insert(1);
assert!(tree.iter().zip(vec![1, 2, 5]).all(|(x, y)| *x == y));

Trait Implementations

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.