Struct std::hashmap::HashSet

pub struct HashSet<T> {
    priv map: HashMap<T, ()>,
}

An implementation of a hash set using the underlying representation of a HashMap where the value is (). As with the HashMap type, a HashSet requires that the elements implement the Eq and Hash traits.

Methods

impl<T: Hash + Eq> HashSet<T>

fn new() -> HashSet<T>

Create an empty HashSet

fn with_capacity(capacity: uint) -> HashSet<T>

Create an empty HashSet with space for at least n elements in the hash table.

fn with_capacity_and_keys(k0: u64, k1: u64, capacity: uint) -> HashSet<T>

Create an empty HashSet with space for at least capacity elements in the hash table, using k0 and k1 as the keys.

Warning: k0 and k1 are normally randomly generated, and are designed to allow HashSets to be resistant to attacks that cause many collisions and very poor performance. Setting them manually using this function can expose a DoS attack vector.

fn reserve_at_least(&mut self, n: uint)

Reserve space for at least n elements in the hash table.

fn contains_equiv<Q: Hash + Equiv<T>>(&self, value: &Q) -> bool

Returns true if the hash set contains a value equivalent to the given query value.

fn iter<'a>(&'a self) -> HashSetIterator<'a, T>

An iterator visiting all elements in arbitrary order. Iterator element type is &'a T.

fn move_iter(self) -> HashSetMoveIterator<T>

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

fn difference_iter<'a>(&'a self, other: &'a HashSet<T>) -> SetAlgebraIter<'a, T>

Visit the values representing the difference

fn symmetric_difference_iter<'a>(&'a self, other: &'a HashSet<T>) -> Chain<SetAlgebraIter<'a, T>, SetAlgebraIter<'a, T>>

Visit the values representing the symmetric difference

fn intersection_iter<'a>(&'a self, other: &'a HashSet<T>) -> SetAlgebraIter<'a, T>

Visit the values representing the intersection

fn union_iter<'a>(&'a self, other: &'a HashSet<T>) -> Chain<HashSetIterator<'a, T>, SetAlgebraIter<'a, T>>

Visit the values representing the union

Trait Implementations

impl<A: ToStr + Hash + Eq> ToStr for HashSet<A>

fn to_str(&self) -> ~str

Converts the value of self to an owned string

impl<T: Hash + Eq> Eq for HashSet<T>

fn eq(&self, other: &HashSet<T>) -> bool

fn ne(&self, other: &HashSet<T>) -> bool

impl<T: Hash + Eq> Container for HashSet<T>

fn len(&self) -> uint

Return the number of elements in the set

impl<T: Hash + Eq> Mutable for HashSet<T>

fn clear(&mut self)

Clear the set, removing all values.

impl<T: Hash + Eq> Set<T> for HashSet<T>

fn contains(&self, value: &T) -> bool

Return true if the set contains a value

fn is_disjoint(&self, other: &HashSet<T>) -> bool

Return true if the set has no elements in common with other. This is equivalent to checking for an empty intersection.

fn is_subset(&self, other: &HashSet<T>) -> bool

Return true if the set is a subset of another

fn is_superset(&self, other: &HashSet<T>) -> bool

Return true if the set is a superset of another

impl<T: Hash + Eq> MutableSet<T> for HashSet<T>

fn insert(&mut self, value: T) -> bool

Add a value to the set. Return true if the value was not already present in the set.

fn remove(&mut self, value: &T) -> bool

Remove a value from the set. Return true if the value was present in the set.

impl<T: Hash + Eq + Clone> Clone for HashSet<T>

fn clone(&self) -> HashSet<T>

Returns a copy of the value. The contents of owned pointers are copied to maintain uniqueness, while the contents of managed pointers are not copied.

impl<K: Eq + Hash> FromIterator<K> for HashSet<K>

fn from_iterator<T: Iterator<K>>(iter: &mut T) -> HashSet<K>

Build a container with elements from an external iterator.

impl<K: Eq + Hash> Extendable<K> for HashSet<K>

fn extend<T: Iterator<K>>(&mut self, iter: &mut T)

Extend a container with the elements yielded by an iterator

impl<K: Eq + Hash> Default for HashSet<K>

fn default() -> HashSet<K>

Return the "default value" for a type.