Struct im::hashset::HashSet
[−]
[src]
pub struct HashSet<A, S = RandomState> { /* fields omitted */ }
A hash set.
An immutable hash set.
This is implemented as a HashMap
with no
values, so it shares the exact performance characteristics of
HashMap
.
Methods
impl<A> HashSet<A, RandomState> where
A: Hash + Eq,
[src]
A: Hash + Eq,
pub fn new() -> Self
[src]
Construct an empty set.
pub fn singleton<R>(a: R) -> Self where
R: Shared<A>,
[src]
R: Shared<A>,
Construct a set with a single value.
Examples
let set = HashSet::singleton(123); assert!(set.contains(&123));
impl<A, S> HashSet<A, S>
[src]
pub fn is_empty(&self) -> bool
[src]
Test whether a set is empty.
Time: O(1)
Examples
assert!( !hashset![1, 2, 3].is_empty() ); assert!( HashSet::<i32>::new().is_empty() );
pub fn len(&self) -> usize
[src]
impl<A, S> HashSet<A, S> where
A: Hash + Eq,
S: BuildHasher,
[src]
A: Hash + Eq,
S: BuildHasher,
pub fn with_hasher<RS>(hasher: RS) -> Self where
RS: Shared<S>,
[src]
RS: Shared<S>,
Construct an empty hash set using the provided hasher.
pub fn new_from<A1>(&self) -> HashSet<A1, S> where
A1: Hash + Eq,
[src]
A1: Hash + Eq,
Construct an empty hash set using the same hasher as the current hash set.
pub fn iter(&self) -> Iter<Arc<A>>
[src]
Get an iterator over the values in a hash set.
Please note that the order is consistent between sets using the same hasher, but no other ordering guarantee is offered. Items will not come out in insertion order or sort order. They will, however, come out in the same order every time for the same set.
pub fn insert<R>(&self, a: R) -> Self where
R: Shared<A>,
[src]
R: Shared<A>,
Insert a value into a set.
Time: O(log n)
Examples
let set = hashset![123]; assert_eq!( set.insert(456), hashset![123, 456] );
pub fn insert_mut<R>(&mut self, a: R) where
R: Shared<A>,
[src]
R: Shared<A>,
Insert a value into a set.
This is a copy-on-write operation, so that the parts of the set's structure which are shared with other sets will be safely copied before mutating.
Time: O(log n)
pub fn contains<BA: ?Sized>(&self, a: &BA) -> bool where
BA: Hash + Eq,
A: Borrow<BA>,
[src]
BA: Hash + Eq,
A: Borrow<BA>,
Test if a value is part of a set.
Time: O(log n)
pub fn remove<BA: ?Sized>(&self, a: &BA) -> Self where
BA: Hash + Eq,
A: Borrow<BA>,
[src]
BA: Hash + Eq,
A: Borrow<BA>,
Remove a value from a set if it exists.
Time: O(log n)
pub fn remove_mut<BA: ?Sized>(&mut self, a: &BA) where
BA: Hash + Eq,
A: Borrow<BA>,
[src]
BA: Hash + Eq,
A: Borrow<BA>,
Remove a value from a set if it exists.
This is a copy-on-write operation, so that the parts of the set's structure which are shared with other sets will be safely copied before mutating.
Time: O(log n)
pub fn union<RS>(&self, other: RS) -> Self where
RS: Borrow<Self>,
[src]
RS: Borrow<Self>,
Construct the union of two sets.
pub fn unions<I>(i: I) -> Self where
I: IntoIterator<Item = Self>,
S: Default,
[src]
I: IntoIterator<Item = Self>,
S: Default,
Construct the union of multiple sets.
pub fn difference<RS>(&self, other: RS) -> Self where
RS: Borrow<Self>,
[src]
RS: Borrow<Self>,
Construct the difference between two sets.
pub fn intersection<RS>(&self, other: RS) -> Self where
RS: Borrow<Self>,
[src]
RS: Borrow<Self>,
Construct the intersection of two sets.
pub fn is_subset<RS>(&self, other: RS) -> bool where
RS: Borrow<Self>,
[src]
RS: Borrow<Self>,
Test whether a set is a subset of another set, meaning that all values in our set must also be in the other set.
pub fn is_proper_subset<RS>(&self, other: RS) -> bool where
RS: Borrow<Self>,
[src]
RS: Borrow<Self>,
Test whether a set is a proper subset of another set, meaning that all values in our set must also be in the other set. A proper subset must also be smaller than the other set.
Trait Implementations
impl<A: Hash + Eq + Ord, S: BuildHasher> From<HashSet<A, S>> for OrdSet<A>
[src]
impl<'a, A: Hash + Eq + Ord, S: BuildHasher> From<&'a HashSet<A, S>> for OrdSet<A>
[src]
impl<A, S> Clone for HashSet<A, S>
[src]
fn clone(&self) -> Self
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<A: Hash + Eq, S: BuildHasher + Default> PartialEq for HashSet<A, S>
[src]
fn eq(&self, other: &Self) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<A: Hash + Eq, S: BuildHasher + Default> Eq for HashSet<A, S>
[src]
impl<A: Hash + Eq + PartialOrd, S: BuildHasher + Default> PartialOrd for HashSet<A, S>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<A: Hash + Eq + Ord, S: BuildHasher + Default> Ord for HashSet<A, S>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl<A: Hash + Eq, S: BuildHasher + Default> Hash for HashSet<A, S>
[src]
fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
H: Hasher,
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<A: Hash + Eq, S: BuildHasher + Default> Default for HashSet<A, S>
[src]
impl<A: Hash + Eq, S: BuildHasher> Add for HashSet<A, S>
[src]
type Output = HashSet<A, S>
The resulting type after applying the +
operator.
fn add(self, other: Self) -> Self::Output
[src]
Performs the +
operation.
impl<A: Hash + Eq, S: BuildHasher> Mul for HashSet<A, S>
[src]
type Output = HashSet<A, S>
The resulting type after applying the *
operator.
fn mul(self, other: Self) -> Self::Output
[src]
Performs the *
operation.
impl<'a, A: Hash + Eq, S: BuildHasher> Add for &'a HashSet<A, S>
[src]
type Output = HashSet<A, S>
The resulting type after applying the +
operator.
fn add(self, other: Self) -> Self::Output
[src]
Performs the +
operation.
impl<'a, A: Hash + Eq, S: BuildHasher> Mul for &'a HashSet<A, S>
[src]
type Output = HashSet<A, S>
The resulting type after applying the *
operator.
fn mul(self, other: Self) -> Self::Output
[src]
Performs the *
operation.
impl<A, S> Sum for HashSet<A, S> where
A: Hash + Eq,
S: BuildHasher + Default,
[src]
A: Hash + Eq,
S: BuildHasher + Default,
fn sum<I>(it: I) -> Self where
I: Iterator<Item = Self>,
[src]
I: Iterator<Item = Self>,
Method which takes an iterator and generates Self
from the elements by "summing up" the items. Read more
impl<A, S, R> Extend<R> for HashSet<A, S> where
A: Hash + Eq,
S: BuildHasher,
R: Shared<A>,
[src]
A: Hash + Eq,
S: BuildHasher,
R: Shared<A>,
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = R>,
[src]
I: IntoIterator<Item = R>,
Extends a collection with the contents of an iterator. Read more
impl<A: Hash + Eq + Debug, S: BuildHasher + Default> Debug for HashSet<A, S>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter. Read more
impl<A: Hash + Eq, RA, S> FromIterator<RA> for HashSet<A, S> where
RA: Shared<A>,
S: BuildHasher + Default,
[src]
RA: Shared<A>,
S: BuildHasher + Default,
fn from_iter<T>(i: T) -> Self where
T: IntoIterator<Item = RA>,
[src]
T: IntoIterator<Item = RA>,
Creates a value from an iterator. Read more
impl<'a, A: Hash + Eq, S: BuildHasher> IntoIterator for &'a HashSet<A, S>
[src]
type Item = Arc<A>
The type of the elements being iterated over.
type IntoIter = Iter<Self::Item>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl<A: Hash + Eq, S: BuildHasher> IntoIterator for HashSet<A, S>
[src]
type Item = Arc<A>
The type of the elements being iterated over.
type IntoIter = Iter<Self::Item>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl<'s, 'a, A: ?Sized, OA, SA, SB> From<&'s HashSet<&'a A, SA>> for HashSet<OA, SB> where
A: ToOwned<Owned = OA> + Hash + Eq,
OA: Borrow<A> + Hash + Eq,
SA: BuildHasher,
SB: BuildHasher + Default,
[src]
A: ToOwned<Owned = OA> + Hash + Eq,
OA: Borrow<A> + Hash + Eq,
SA: BuildHasher,
SB: BuildHasher + Default,