An ordered map and set for integer keys implemented as a radix trie
TrieMap
TrieSet
of Container for TrieMap<T> where <T>
of Mutable for TrieMap<T> where <T>
of Map<uint, T> for TrieMap<T> where <T>
for TrieMap<T> where <T>
of Container for TrieSet
of Mutable for TrieSet
for TrieSet
TrieMap
pub struct TrieMap<T> {
priv root: TrieNode<T>,
priv length: uint,
}
TrieSet
pub struct TrieSet {
priv map: TrieMap<()>,
}
Container
for TrieMap<T>
where <T>
len
fn len(&self) -> uint
Return the number of elements in the map
is_empty
fn is_empty(&self) -> bool
Return true if the map contains no elements
Mutable
for TrieMap<T>
where <T>
clear
fn clear(&mut self)
Clear the map, removing all values.
Map<uint, T>
for TrieMap<T>
where <T>
contains_key
fn contains_key(&self, key: &uint) -> bool
Return true if the map contains a value for the specified key
find
fn find<'a>(&'a self, key: &uint) -> Option<&'a T>
Return a reference to the value corresponding to the key
find_mut
fn find_mut<'a>(&'a mut self, key: &uint) -> Option<&'a mut T>
Return a mutable reference to the value corresponding to the key
insert
fn insert(&mut self, key: uint, value: T) -> bool
Insert a key-value pair into the map. An existing value for a key is replaced by the new value. Return true if the key did not already exist in the map.
remove
fn remove(&mut self, key: &uint) -> bool
Remove a key-value pair from the map. Return true if the key was present in the map, otherwise false.
swap
fn swap(&mut self, key: uint, value: T) -> Option<T>
Insert a key-value pair from the map. If the key already had a value present in the map, that value is returned. Otherwise None is returned.
pop
fn pop(&mut self, key: &uint) -> Option<T>
Removes a key from the map, returning the value at the key if the key was previously in the map.
TrieMap<T>
where <T>
new
fn new() -> TrieMap<T>
Create an empty TrieMap
each_reverse
fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool
Visit all key-value pairs in reverse order
each
fn each<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool
Visit all key-value pairs in order
each_key
fn each_key(&self, f: &fn(&uint) -> bool) -> bool
Visit all keys in order
each_value
fn each_value<'a>(&'a self, f: &fn(&'a T) -> bool) -> bool
Visit all values in order
mutate_values
fn mutate_values(&mut self, f: &fn(&uint, &mut T) -> bool) -> bool
Iterate over the map and mutate the contained values
each_key_reverse
fn each_key_reverse(&self, f: &fn(&uint) -> bool) -> bool
Visit all keys in reverse order
each_value_reverse
fn each_value_reverse(&self, f: &fn(&T) -> bool) -> bool
Visit all values in reverse order
Container
for TrieSet
len
fn len(&self) -> uint
Return the number of elements in the set
is_empty
fn is_empty(&self) -> bool
Return true if the set contains no elements
Mutable
for TrieSet
clear
fn clear(&mut self)
Clear the set, removing all values.
TrieSet
new
fn new() -> TrieSet
Create an empty TrieSet
contains
fn contains(&self, value: &uint) -> bool
Return true if the set contains a value
insert
fn insert(&mut self, value: uint) -> bool
Add a value to the set. Return true if the value was not already present in the set.
remove
fn remove(&mut self, value: &uint) -> bool
Remove a value from the set. Return true if the value was present in the set.
each
fn each(&self, f: &fn(&uint) -> bool) -> bool
Visit all values in order
each_reverse
fn each_reverse(&self, f: &fn(&uint) -> bool) -> bool
Visit all values in reverse order