[][src]Struct tst::tst_set::TSTSet

pub struct TSTSet { /* fields omitted */ }

A set based on a TSTMap.

Methods

impl TSTSet[src]

pub fn new() -> Self[src]

Makes a new empty TSTSet.

Examples

use tst::TSTSet;

let mut s: TSTSet = TSTSet::new();

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

Returns the number of elements in the set.

Examples

use tst::TSTSet;

let mut s: TSTSet = TSTSet::new();
assert_eq!(s.len(), 0);
s.insert("xxx");
assert_eq!(s.len(), 1);

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

Returns true if the set contains no elements.

Examples

use tst::TSTSet;

let mut s: TSTSet = TSTSet::new();
assert!(s.is_empty());
s.insert("yyyx");
assert!(!s.is_empty());

pub fn clear(&mut self)[src]

Clears the set, removing all values.

Examples

use tst::TSTSet;

let mut s: TSTSet = TSTSet::new();
s.insert("abc");
s.insert("abd");
s.clear();

assert!(s.is_empty());
assert!(!s.contains("abc"));

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

Returns true if the set contains a key.

Examples

use tst::TSTSet;

let mut s: TSTSet = TSTSet::new();
s.insert("abc");
assert!(!s.contains("ab"));
assert!(s.contains("abc"));

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

Adds a value to the set.

If the set did not have a value present, true is returned.

Examples

use tst::TSTSet;

let mut s: TSTSet = TSTSet::new();

assert!(s.insert("abcd"));
assert!(!s.insert("abcd"));
assert_eq!(s.len(), 1);

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

Removes a value from the set. Returns true if the value was present in the set.

Examples

use tst::TSTSet;

let mut s: TSTSet = TSTSet::new();

s.insert("acde");
assert!(s.remove("acde"));
assert!(!s.remove("acde"));

Important traits for Iter<'a>
pub fn iter(&self) -> Iter[src]

Gets an iterator over the TSTSet's contents.

Examples

use tst::TSTSet;

let mut s: TSTSet = TSTSet::new();
s.insert("abc");
s.insert("bde");
s.insert("cfgx");
for x in s.iter() {
    println!("{}", x);
}

Important traits for WildCardIter<'a>
pub fn wildcard_iter(&self, pat: &str) -> WildCardIter[src]

An iterator returning all nodes matching wildcard pattern. Iterator element type is (String)

Examples

use tst::TSTSet;

let mut s = TSTSet::new();
s.insert("a");
s.insert("b");
s.insert("c");

for x in s.wildcard_iter(".") {
    println!("{}", x);
}

pub fn longest_prefix<'a>(&self, pref: &'a str) -> &'a str[src]

Method returns longest prefix in the TSTSet.

Examples

use tst::TSTSet;
let mut set = TSTSet::new();
set.insert("abc");
set.insert("abcd");
set.insert("abce");
set.insert("abca");
set.insert("zxd");
set.insert("add");
set.insert("abcdef");

assert_eq!("abcd", set.longest_prefix("abcde"));

Important traits for Iter<'a>
pub fn prefix_iter(&self, pref: &str) -> Iter[src]

Method returns iterator over all values with common prefix in the TSTSet.

Examples

use tst::TSTSet;
let mut set = TSTSet::new();
set.insert("abc");
set.insert("abcd");
set.insert("abce");
set.insert("abca");
set.insert("zxd");
set.insert("add");
set.insert("abcdef");

for key in set.prefix_iter("abc") {
    println!("{}", key);
}

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

Trait Implementations

impl IntoIterator for TSTSet[src]

type Item = String

The type of the elements being iterated over.

type IntoIter = IntoIter

Which kind of iterator are we turning this into?

Important traits for IntoIter
fn into_iter(self) -> IntoIter[src]

Creates a consuming iterator, that is, one that moves each key-value pair out of the TSTMap in arbitrary order. The TSTMap cannot be used after calling this.

Examples

use tst::TSTSet;

let mut set = TSTSet::new();
set.insert("a");
set.insert("b");
set.insert("c");

let vec: Vec<String> = set.into_iter().collect();

impl Eq for TSTSet[src]

impl Clone for TSTSet[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'x> Extend<&'x str> for TSTSet[src]

impl PartialEq<TSTSet> for TSTSet[src]

impl Default for TSTSet[src]

fn default() -> Self[src]

Makes a new empty TSTSet.

Examples

use tst::TSTSet;

let mut s: TSTSet = TSTSet::new();

impl<'x> FromIterator<&'x str> for TSTSet[src]

impl Debug for TSTSet[src]

Auto Trait Implementations

impl Send for TSTSet

impl Sync for TSTSet

Blanket Implementations

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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