Struct panoradix::set::RadixSet [] [src]

pub struct RadixSet<K: Key + ?Sized> { /* fields omitted */ }

A set based on a Radix tree.

See RadixMap for an in-depth explanation of the workings of this struct, as it's simply a wrapper around RadixMap<K, ()>.

Methods

impl<K: Key + ?Sized> RadixSet<K>
[src]

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");

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());

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);

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.contains("a"), true);
assert_eq!(set.contains("b"), false);

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());

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);

Gets an iterator over the keys inserted (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.iter() {
    println!("{}", key);
}

let first_key = set.iter().next().unwrap();
assert_eq!(first_key, "a".to_string());

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]

Returns the "default value" for a type. Read more

impl<K: Key + ?Sized, T: AsRef<K>> FromIterator<T> for RadixSet<K>
[src]

Creates a value from an iterator. Read more