Struct im::hashset::HashSet
[−]
[src]
pub struct HashSet<A, S = RandomState>(_);
A hash set.
An immutable hash set backed by a HashMap
.
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,
fn new() -> Self
[src]
Construct an empty set.
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]
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() );
fn len(&self) -> usize
[src]
fn iter(&self) -> Iter<A>
[src]
impl<A, S> HashSet<A, S> where
A: Hash + Eq,
S: SharedHasher,
[src]
A: Hash + Eq,
S: SharedHasher,
fn with_hasher(hasher: &Arc<S>) -> Self
[src]
Construct an empty hash set using the provided hasher.
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.
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] );
fn insert_mut<R>(&mut self, a: R) where
R: Shared<A>,
[src]
R: Shared<A>,
Insert a value into a set, mutating it in place when it is safe to do so.
If you are the sole owner of the set, it is safe to mutate it without
losing immutability guarantees, gaining us a considerable performance
advantage. If the set is in use elsewhere, this operation will safely
clone the map before mutating it, acting just like the immutable insert
operation.
Time: O(log n)
fn contains(&self, a: &A) -> bool
[src]
Test if a value is part of a set.
Time: O(log n)
fn remove(&self, a: &A) -> Self
[src]
Remove a value from a set.
fn remove_mut(&mut self, a: &A)
[src]
Remove a value from a set if it exists, mutating it in place when it is safe to do so.
If you are the sole owner of the set, it is safe to mutate it without
losing immutability guarantees, gaining us a considerable performance
advantage. If the set is in use elsewhere, this operation will safely
clone the map before mutating it, acting just like the immutable insert
operation.
Time: O(log n)
fn union(&self, other: &Self) -> Self
[src]
Construct the union of two sets.
fn unions<I>(i: I) -> Self where
I: IntoIterator<Item = Self>,
[src]
I: IntoIterator<Item = Self>,
Construct the union of multiple sets.
fn difference<RS>(&self, other: RS) -> Self where
RS: Borrow<Self>,
[src]
RS: Borrow<Self>,
Construct the difference between two sets.
fn intersection<RS>(&self, other: RS) -> Self where
RS: Borrow<Self>,
[src]
RS: Borrow<Self>,
Construct the intersection of two sets.
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.
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, 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> 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> Eq for HashSet<A, S>
[src]
impl<A: Hash + Eq + PartialOrd, S> 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> 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.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.22.0[src]
Compares and returns the minimum of two values. Read more
impl<A: Hash + Eq, S: SharedHasher> 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: SharedHasher> Default for HashSet<A, S>
[src]
impl<'a, A: Hash + Eq, S: SharedHasher> 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: SharedHasher> 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: Hash + Eq + Debug, S: SharedHasher> Debug for HashSet<A, S>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter.
impl<A: Hash + Eq, RA, S> FromIterator<RA> for HashSet<A, S> where
RA: Shared<A>,
S: SharedHasher,
[src]
RA: Shared<A>,
S: SharedHasher,
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, S> IntoIterator for &'a HashSet<A, S>
[src]
type Item = Arc<A>
The type of the elements being iterated over.
type IntoIter = Iter<A>
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, S> IntoIterator for HashSet<A, S>
[src]
type Item = Arc<A>
The type of the elements being iterated over.
type IntoIter = Iter<A>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more