logo
pub struct HashSet<T> where
    T: Hash + Eq
{ /* private fields */ }
Expand description

A hash set implementation based on HashMap.

References:

Implementations

Creates an empty set.

Gets the number of non-repetitive elements, equivalently to the cardinality of a set.

Complexity

Constant.

Returns whether there is no any element in the set.

Complexity

Constant.

Inserts an element into the set.

Returns true if there were no such element in the set; returns false if an identical element is already in the set.

Parameters
  • value - Element to be inserted.
Complexity

Constant.

Returns whether an element is present in the set.

This is equivalent to “belongs to ∈” relation in mathematics.

Parameters
  • value - Element to be checked whether is in the set.
Complexity

Constant.

Removes an element from the set.

Returns true if such item was present and removed; returns false if no such item was found in the set.

Parameters
  • value - Element to be removed.
Complexity

Constant.

Creates an iterator yielding immutable reference of each item in arbitrary order.

Returns an iterator visiting items that exists in self, in other, or in both self and other

This is equivalent to self ∪ other in mathematics.

Parameters
  • other - The other set.

Returns an iterator visiting items that exists in self but not in other.

This is equivalent to self \ other in mathematics.

Parameters
  • other - The other set.

Returns an iterator visiting items that only exists in either self or other but not in their intersection.

This is equivalent to self △ other in mathematics.

Parameters
  • other - The other set.

Returns an iterator visiting items that exists in both self and other.

This is equivalent to self ∩ other in mathematics.

Parameters
  • other - The other set.

Returns true if self has no elements in common with other.

This is equivalent to checking for an empty intersection, which means their intersection is the empty set ∅.

Parameters
  • other - The other set.
Complexity

Linear in the size of self.

Returns true if other contains at least all elements in self.

This is equivalent to self ⊆ other in mathematics.

Parameters
  • other - The other set.
Complexity

Linear in the size of self.

Returns true if self contains at least all elements in other.

This is equivalent to self ⊇ other in mathematics.

Parameters
  • other - The other set.
Complexity

Linear in the size of other.

Trait Implementations

The bit_and operator &, as an alias of intersection().

The resulting type after applying the & operator.

Performs the & operation. Read more

The bitor operator |, as an alias of union().

The resulting type after applying the | operator.

Performs the | operation. Read more

The bitxor operator ^, as an alias of symmetric_difference().

The resulting type after applying the ^ operator.

Performs the ^ operation. Read more

Returns the “default value” for a type. Read more

Creates a value from an iterator. Read more

Checks the equality of sets.

Two sets are defined to be equal if they contain the same elements and their cardinality are equal.

Set theory definition: x = y ⇒ ∀z, (z ∈ x ⇔ z ∈ y)

Parameters
  • other - The other set.
Complexity

Linear in the size of self.

This method tests for !=.

Compares sets to determine whether one is a subset of the other or not.

Parameters
  • other - The other set.
Complexity

Linear in the size of max(self, other).

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

The sub operator -, as an alias of difference().

The resulting type after applying the - operator.

Performs the - operation. Read more

A set is reflecxively equal to itself.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.