pub struct HashSet<T>{ /* private fields */ }
Expand description
A hash set implementation based on HashMap
.
References:
Implementations§
Source§impl<T> HashSet<T>
impl<T> HashSet<T>
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Gets the number of non-repetitive elements, equivalently to the cardinality of a set.
§Complexity
Constant.
Sourcepub fn iter(&self) -> impl Iterator<Item = &T>
pub fn iter(&self) -> impl Iterator<Item = &T>
Creates an iterator yielding immutable reference of each item in arbitrary order.
Sourcepub fn union<'a>(&'a self, other: &'a HashSet<T>) -> impl Iterator<Item = &T>
pub fn union<'a>(&'a self, other: &'a HashSet<T>) -> impl Iterator<Item = &T>
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.
Sourcepub fn difference<'a>(
&'a self,
other: &'a HashSet<T>,
) -> impl Iterator<Item = &T>
pub fn difference<'a>( &'a self, other: &'a HashSet<T>, ) -> impl Iterator<Item = &T>
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.
Sourcepub fn symmetric_difference<'a>(
&'a self,
other: &'a HashSet<T>,
) -> impl Iterator<Item = &T>
pub fn symmetric_difference<'a>( &'a self, other: &'a HashSet<T>, ) -> impl Iterator<Item = &T>
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.
Sourcepub fn intersection<'a>(
&'a self,
other: &'a HashSet<T>,
) -> impl Iterator<Item = &T>
pub fn intersection<'a>( &'a self, other: &'a HashSet<T>, ) -> impl Iterator<Item = &T>
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.
Sourcepub fn is_disjoint(&self, other: &HashSet<T>) -> bool
pub fn is_disjoint(&self, other: &HashSet<T>) -> bool
Trait Implementations§
Source§impl<'a, 'b, T> BitAnd<&'b HashSet<T>> for &'a HashSet<T>
The bit_and operator &
, as an alias of intersection().
impl<'a, 'b, T> BitAnd<&'b HashSet<T>> for &'a HashSet<T>
The bit_and operator &
, as an alias of intersection().
Source§impl<'a, 'b, T> BitOr<&'b HashSet<T>> for &'a HashSet<T>
The bitor operator |
, as an alias of union()
.
impl<'a, 'b, T> BitOr<&'b HashSet<T>> for &'a HashSet<T>
The bitor operator |
, as an alias of union()
.
Source§impl<'a, 'b, T> BitXor<&'b HashSet<T>> for &'a HashSet<T>
The bitxor operator ^
, as an alias of symmetric_difference()
.
impl<'a, 'b, T> BitXor<&'b HashSet<T>> for &'a HashSet<T>
The bitxor operator ^
, as an alias of symmetric_difference()
.
Source§impl<T> FromIterator<T> for HashSet<T>
impl<T> FromIterator<T> for HashSet<T>
Source§fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = T>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = T>,
Source§impl<T> PartialOrd for HashSet<T>
impl<T> PartialOrd for HashSet<T>
Source§impl<'a, 'b, T> Sub<&'b HashSet<T>> for &'a HashSet<T>
The sub operator -
, as an alias of difference()
.
impl<'a, 'b, T> Sub<&'b HashSet<T>> for &'a HashSet<T>
The sub operator -
, as an alias of difference()
.
impl<T> Eq for HashSet<T>
A set is reflecxively equal to itself.