Struct tst::TSTSet [] [src]

pub struct TSTSet {
    // some fields omitted
}

A set based on a TSTMap.

Methods

impl TSTSet
[src]

fn new() -> TSTSet

Makes a new empty TSTSet.

Examples

use tst::TSTSet;

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

fn len(&self) -> usize

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

fn is_empty(&self) -> bool

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

fn clear(&mut self)

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

fn contains(&self, key: &str) -> bool

Returns true if the set contains a value.

Examples

use tst::TSTSet;

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

fn insert(&mut self, key: &str) -> bool

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

fn remove(&mut self, key: &str) -> bool

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

fn iter(&self) -> Iter

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

fn wildcard_iter(&self, pat: &str) -> WildCardIter

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

fn longest_prefix<'a>(&self, pref: &'a str) -> &'a str

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

fn prefix_iter(&self, pref: &str) -> Iter

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 Eq for TSTSet
[src]

impl PartialEq for TSTSet
[src]

fn eq(&self, __arg_0: &TSTSet) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &TSTSet) -> bool

This method tests for !=.

impl Clone for TSTSet
[src]

fn clone(&self) -> TSTSet

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more

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?

fn into_iter(self) -> IntoIter

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<'x> FromIterator<&'x str> for TSTSet
[src]

fn from_iter<I: IntoIterator<Item=&'x str>>(iter: I) -> TSTSet

Creates a value from an iterator. Read more

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

fn extend<I: IntoIterator<Item=&'x str>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more

impl Debug for TSTSet
[src]

fn fmt(&self, f: &mut Formatter) -> Result

Formats the value using the given formatter.