Struct panoradix::RadixSet
[−]
[src]
pub struct RadixSet<K: Key + ?Sized> { /* fields omitted */ }
A set based on a Radix tree.
TODO: section on benefits/drawbacks of using a Radix tree
Methods
impl<K: Key + ?Sized> RadixSet<K>
[src]
fn new() -> RadixSet<K>
Makes a new empty RadixSet.
Examples
Basic usage:
use panoradix::RadixSet; let mut set = RadixSet::new(); // entries can now be inserted into the empty set set.insert("a");
fn clear(&mut self)
Clears the set, removing all values.
Examples
Basic usage:
use panoradix::RadixSet; let mut set = RadixSet::new(); set.insert("a"); set.clear(); assert!(set.is_empty());
fn insert(&mut self, key: &K) -> bool
Inserts a key into the set.
If the set did not have this key present, true
is returned, otherwise false
is
returned.
Examples
Basic usage:
use panoradix::RadixSet; let mut set = RadixSet::new(); assert_eq!(set.insert("a"), true); assert_eq!(set.is_empty(), false); assert_eq!(set.insert("a"), false);
fn has_key(&self, key: &K) -> bool
Returns if the key is present in the set.
Examples
Basic usage:
use panoradix::RadixSet; let mut set = RadixSet::new(); set.insert("a"); assert_eq!(set.has_key("a"), true); assert_eq!(set.has_key("b"), false);
fn is_empty(&self) -> bool
Returns true
if the set contains no elements.
Examples
Basic usage:
use panoradix::RadixSet; let mut set = RadixSet::new(); assert!(set.is_empty()); set.insert("a"); assert!(!set.is_empty());
fn remove(&mut self, key: &K) -> bool
Removes a key from the set, returning if the key was previously in the map.
Examples
Basic usage:
use panoradix::RadixSet; let mut set = RadixSet::new(); set.insert("a"); assert_eq!(set.remove("a"), true); assert_eq!(set.remove("a"), false);
fn keys(&self) -> MapKeys<'a, K, ()>
Gets an iterator over the keys of the map (sorted).
Examples
Basic usage:
use panoradix::RadixSet; let mut set = RadixSet::new(); set.insert("c"); set.insert("b"); set.insert("a"); for key in set.keys() { println!("{}", key); } let first_key = set.keys().next().unwrap(); assert_eq!(first_key, "a".to_string());
fn iter(&self) -> MapKeys<'a, K, ()>
Gets an iterator over the keys of the map (sorted).
This method is strictly equivalent to the keys()
method.
fn find<'a>(&'a self, key: &K) -> Matches<'a, K>
Gets an iterator over a filtered subset of the set (sorted).
Note that the full key will be yielded each time, not just the filtered suffix.
Examples
Basic usage:
use panoradix::RadixSet; let mut set = RadixSet::new(); set.insert("abc"); set.insert("acd"); set.insert("abd"); set.insert("bbb"); set.insert("ccc"); for key in set.find("a") { println!("{}", key); } let first_key = set.find("a").next().unwrap(); assert_eq!(first_key, "abc".to_string());
Trait Implementations
impl<K: Key + ?Sized> Default for RadixSet<K>
[src]
impl<K: Key + ?Sized, T: AsRef<K>> FromIterator<T> for RadixSet<K>
[src]
fn from_iter<It>(iter: It) -> Self where
It: IntoIterator<Item = T>,
It: IntoIterator<Item = T>,
Creates a value from an iterator. Read more