Struct patricia_tree::set::PatriciaSet
[−]
[src]
pub struct PatriciaSet { /* fields omitted */ }
A set based on a patricia tree.
Methods
impl PatriciaSet
[src]
fn new() -> Self
[src]
Makes a new empty PatriciaSet
instance.
Examples
use patricia_tree::PatriciaSet; let set = PatriciaSet::new(); assert!(set.is_empty());
fn len(&self) -> usize
[src]
Returns the number of elements in this set.
Examples
use patricia_tree::PatriciaSet; let mut set = PatriciaSet::new(); set.insert("foo"); set.insert("bar"); assert_eq!(set.len(), 2);
fn is_empty(&self) -> bool
[src]
Returns true if this set contains no elements.
Examples
use patricia_tree::PatriciaSet; let mut set = PatriciaSet::new(); assert!(set.is_empty()); set.insert("foo"); assert!(!set.is_empty()); set.clear(); assert!(set.is_empty());
fn clear(&mut self)
[src]
Clears this set, removing all values.
Examples
use patricia_tree::PatriciaSet; let mut set = PatriciaSet::new(); set.insert("foo"); set.clear(); assert!(set.is_empty());
fn contains<T: AsRef<[u8]>>(&self, value: T) -> bool
[src]
Returns true
if this set contains a value.
Examples
use patricia_tree::PatriciaSet; let mut set = PatriciaSet::new(); set.insert("foo"); assert!(set.contains("foo")); assert!(!set.contains("bar"));
fn insert<T: AsRef<[u8]>>(&mut self, value: T) -> bool
[src]
Adds a value to this set.
If the set did not have this value present, true
is returned.
If the set did have this value present, false
is returned, and the entry is not updated.
Examples
use patricia_tree::PatriciaSet; let mut set = PatriciaSet::new(); assert!(set.insert("foo")); assert!(!set.insert("foo")); assert_eq!(set.len(), 1);
fn remove<T: AsRef<[u8]>>(&mut self, value: T) -> bool
[src]
Removes a value from the set. Returns true
is the value was present in this set.
Examples
use patricia_tree::PatriciaSet; let mut set = PatriciaSet::new(); set.insert("foo"); assert_eq!(set.remove("foo"), true); assert_eq!(set.remove("foo"), false);
fn iter(&self) -> Iter
[src]
Gets an iterator over the contents of this set, in sorted order.
Examples
use patricia_tree::PatriciaSet; let mut set = PatriciaSet::new(); set.insert("foo"); set.insert("bar"); set.insert("baz"); assert_eq!(set.iter().collect::<Vec<_>>(), [Vec::from("bar"), "baz".into(), "foo".into()]);
Trait Implementations
impl Default for PatriciaSet
[src]
fn default() -> PatriciaSet
[src]
Returns the "default value" for a type. Read more
impl Clone for PatriciaSet
[src]
fn clone(&self) -> PatriciaSet
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for PatriciaSet
[src]
impl IntoIterator for PatriciaSet
[src]
type Item = Vec<u8>
The type of the elements being iterated over.
type IntoIter = IntoIter
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl<T: AsRef<[u8]>> FromIterator<T> for PatriciaSet
[src]
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = T>,
[src]
I: IntoIterator<Item = T>,
Creates a value from an iterator. Read more
impl<T: AsRef<[u8]>> Extend<T> for PatriciaSet
[src]
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = T>,
[src]
I: IntoIterator<Item = T>,
Extends a collection with the contents of an iterator. Read more