Struct HashSet

Source
pub struct HashSet<T> { /* private fields */ }

Implementations§

Source§

impl<T> HashSet<T>
where T: Clone + Default + Debug + Hash + Eq + PartialEq,

Source

pub fn new() -> Self

Constructor for an empty set with a default capacity of 2 because everyone deserves a friend.

Source

pub fn new_with_capacity(size: usize) -> Self

Constructor for an empty set with a given capacity.

Source

pub fn size(&self) -> usize

Returns the number of elements in the set.

Source

pub fn is_empty(&self) -> bool

Returns true if the set is either empty or contains only empty slots and deleted entries.

Source

pub fn put(&mut self, elem: T)

Adds an item to the set.

Source

pub fn remove(&mut self, elem: T) -> Option<T>

Removes an item from the set.

Source

pub fn contains<Q>(&self, elem: &Q) -> bool
where T: Borrow<Q>, Q: Debug + Hash + Eq + ?Sized,

Returns true if the set contains the referenced element.

Source

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.

Source

pub fn extend(&mut self, other: Self)

A mutating version of union() that consumes other to add all of its elements to self.

Source

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.

Source

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”.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<T> Default for HashSet<T>
where T: Clone + Default + Debug + Hash + Eq + PartialEq,

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<T> Freeze for HashSet<T>

§

impl<T> RefUnwindSafe for HashSet<T>
where T: RefUnwindSafe,

§

impl<T> Send for HashSet<T>
where T: Send,

§

impl<T> Sync for HashSet<T>
where T: Sync,

§

impl<T> Unpin for HashSet<T>
where T: Unpin,

§

impl<T> UnwindSafe for HashSet<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V