pub struct HashSet<T> { /* private fields */ }Implementations§
Source§impl<T> HashSet<T>
impl<T> HashSet<T>
Sourcepub fn new() -> Self
pub fn new() -> Self
Constructor for an empty set with a default capacity of 2 because everyone deserves a friend.
Sourcepub fn new_with_capacity(size: usize) -> Self
pub fn new_with_capacity(size: usize) -> Self
Constructor for an empty set with a given capacity.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the set is either empty or contains only empty slots and deleted entries.
Sourcepub fn contains<Q>(&self, elem: &Q) -> bool
pub fn contains<Q>(&self, elem: &Q) -> bool
Returns true if the set contains the referenced element.
Sourcepub fn union<'a>(&'a self, other: &'a Self) -> Union<'a, T> ⓘ
pub fn union<'a>(&'a self, other: &'a Self) -> Union<'a, T> ⓘ
Returns an iterator over references to all elements that appear
in either self or other as a set-theoretic
union.
Sourcepub fn extend(&mut self, other: Self)
pub fn extend(&mut self, other: Self)
A mutating version of union() that consumes other to add
all of its elements to self.
Sourcepub fn intersection<'a>(&'a self, other: &'a Self) -> Intersection<'a, T> ⓘ
pub fn intersection<'a>(&'a self, other: &'a Self) -> Intersection<'a, T> ⓘ
Returns an iterator over references to elements that appear
in both self and other as a set-theoretic
intersection.
Sourcepub fn retain_all(&mut self, other: &Self)
pub fn retain_all(&mut self, other: &Self)
Mutates self such that self only keeps elements that are also in other.
Different from the function retain which takes a closure to only retain elements
according to the predicate.
NOTE: This function could also appropriately be called “intersect”, but that was too close to the non-mutating version of this function called “intersection”.
Sourcepub fn difference<'a>(&'a self, other: &'a Self) -> Difference<'a, T> ⓘ
pub fn difference<'a>(&'a self, other: &'a Self) -> Difference<'a, T> ⓘ
Returns an iterator over references to elements that are present
in self but not in other as a set-theoretic asymmetric difference
or relative complement.
This operation is asymmetric: interchanging self and other
generally produces different results.
Sourcepub fn unique<'a>(&'a self, other: &'a Self) -> Unique<'a, T> ⓘ
pub fn unique<'a>(&'a self, other: &'a Self) -> Unique<'a, T> ⓘ
Returns an iterator over references to elements that are present
in exactly one of the two sets as a set-theoretic symmetric
difference.
This operation is symmetric: interchanging self and other
yields the same result.