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

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]

pub fn new() -> 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");

pub fn clear(&mut self)[src]

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

pub fn len(&self) -> usize[src]

Return the number of elements in the set.

Examples

Basic usage:

use panoradix::RadixSet;

let mut s = RadixSet::new();
s.insert("a");
s.insert("b");
s.insert("c");
assert_eq!(s.len(), 3);

pub fn insert(&mut self, key: &K) -> bool[src]

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

pub fn contains(&self, key: &K) -> bool[src]

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

pub fn is_empty(&self) -> bool[src]

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

pub fn remove(&mut self, key: &K) -> bool[src]

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

pub fn iter(&self) -> Iter<K>[src]

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

Important traits for Matches<'a, K>
pub fn find<'a>(&'a self, key: &K) -> Matches<'a, K>[src]

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]

Auto Trait Implementations

impl<K: ?Sized> RefUnwindSafe for RadixSet<K> where
    <K as Key>::Component: RefUnwindSafe

impl<K: ?Sized> Send for RadixSet<K> where
    <K as Key>::Component: Send

impl<K: ?Sized> Sync for RadixSet<K> where
    <K as Key>::Component: Sync

impl<K: ?Sized> Unpin for RadixSet<K> where
    <K as Key>::Component: Unpin

impl<K: ?Sized> UnwindSafe for RadixSet<K> where
    <K as Key>::Component: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.