[−][src]Struct im::HashSet
An unordered set.
An immutable hash set using hash array mapped tries.
Most operations on this set are O(logx n) for a
suitably high x that it should be nearly O(1) for most sets.
Because of this, it's a great choice for a generic set as long as
you don't mind that values will need to implement
Hash
and Eq
.
Values will have a predictable order based on the hasher being
used. Unless otherwise specified, all sets will use the default
RandomState
hasher,
which will produce consistent hashes for the duration of its
lifetime, but not between restarts of your program.
Methods
impl<A> HashSet<A, RandomState> where
A: Hash + Eq + Clone,
[src]
impl<A> HashSet<A, RandomState> where
A: Hash + Eq + Clone,
| [src] |
Construct an empty set.
| [src] |
renamed to unit
for consistency
Construct a set with a single value.
This method has been deprecated; use unit
instead.
| [src] |
Construct a set with a single value.
Examples
let set = HashSet::unit(123); assert!(set.contains(&123));
impl<A, S> HashSet<A, S>
[src]
impl<A, S> HashSet<A, S>
| [src] |
Test whether a set is empty.
Time: O(1)
Examples
assert!( !hashset![1, 2, 3].is_empty() ); assert!( HashSet::<i32>::new().is_empty() );
| [src] |
impl<A, S> HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
[src]
impl<A, S> HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
| [src] |
Construct an empty hash set using the provided hasher.
| [src] |
Get a reference to the set's BuildHasher
.
| [src] |
Construct an empty hash set using the same hasher as the current hash set.
ⓘImportant traits for Iter<'a, 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.
ⓘImportant traits for IterMut<'a, A>
| [src] |
Get a mutable 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.
| [src] |
Test if a value is part of a set.
Time: O(log n)
pub fn insert(&mut self, a: A) -> Option<A> | [src] |
Insert a value into a set.
Time: O(log n)
pub fn remove<BA: ?Sized>(&mut self, a: &BA) -> Option<A> where | [src] |
Remove a value from a set if it exists.
Time: O(log n)
pub fn clear(&mut self) | [src] |
Discard all elements from the set.
This leaves you with an empty set, and all elements that were previously inside it are dropped.
Time: O(n)
Examples
let mut set = hashset![1, 2, 3]; set.clear(); assert!(set.is_empty());
| [src] |
Construct a new set from the current set with the given value added.
Time: O(log n)
Examples
let set = hashset![123]; assert_eq!( set.update(456), hashset![123, 456] );
| [src] |
Construct a new set with the given value removed if it's in the set.
Time: O(log n)
pub fn retain<F>(&mut self, f: F) where | [src] |
Filter out values from a set which don't satisfy a predicate.
This is slightly more efficient than filtering using an iterator, in that it doesn't need to rehash the retained values, but it still needs to reconstruct the entire tree structure of the set.
Time: O(n log n)
| [src] |
Construct the union of two sets.
Time: O(n log n)
Examples
let set1 = hashset!{1, 2}; let set2 = hashset!{2, 3}; let expected = hashset!{1, 2, 3}; assert_eq!(expected, set1.union(set2));
| [src] |
Construct the union of multiple sets.
Time: O(n log n)
| [src] |
Construct the difference between two sets.
Time: O(n log n)
Examples
let set1 = hashset!{1, 2}; let set2 = hashset!{2, 3}; let expected = hashset!{1, 3}; assert_eq!(expected, set1.difference(set2));
| [src] |
Construct the intersection of two sets.
Time: O(n log n)
Examples
let set1 = hashset!{1, 2}; let set2 = hashset!{2, 3}; let expected = hashset!{2}; assert_eq!(expected, set1.intersection(set2));
| [src] |
Test whether a set is a subset of another set, meaning that all values in our set must also be in the other set.
Time: O(n log n)
| [src] |
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.
Time: O(n log n)
Trait Implementations
impl<A: Hash + Eq + Ord + Clone, S: BuildHasher> From<HashSet<A, S>> for OrdSet<A>
[src]
impl<A: Hash + Eq + Ord + Clone, S: BuildHasher> From<HashSet<A, S>> for OrdSet<A>
impl<'a, A: Hash + Eq + Ord + Clone, S: BuildHasher> From<&'a HashSet<A, S>> for OrdSet<A>
[src]
impl<'a, A: Hash + Eq + Ord + Clone, S: BuildHasher> From<&'a HashSet<A, S>> for OrdSet<A>
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 + Clone,
SA: BuildHasher,
SB: BuildHasher + Default,
[src]
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 + Clone,
SA: BuildHasher,
SB: BuildHasher + Default,
impl<'a, A, S> From<&'a [A]> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
impl<'a, A, S> From<&'a [A]> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
impl<A, S> From<Vec<A>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
impl<A, S> From<Vec<A>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
impl<'a, A, S> From<&'a Vec<A>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
impl<'a, A, S> From<&'a Vec<A>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
impl<A, S> From<HashSet<A, RandomState>> for HashSet<A, S> where
A: Eq + Hash + Clone,
S: BuildHasher + Default,
[src]
impl<A, S> From<HashSet<A, RandomState>> for HashSet<A, S> where
A: Eq + Hash + Clone,
S: BuildHasher + Default,
impl<'a, A, S> From<&'a HashSet<A, RandomState>> for HashSet<A, S> where
A: Eq + Hash + Clone,
S: BuildHasher + Default,
[src]
impl<'a, A, S> From<&'a HashSet<A, RandomState>> for HashSet<A, S> where
A: Eq + Hash + Clone,
S: BuildHasher + Default,
impl<'a, A, S> From<&'a BTreeSet<A>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
impl<'a, A, S> From<&'a BTreeSet<A>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
impl<A, S> From<OrdSet<A>> for HashSet<A, S> where
A: Ord + Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
impl<A, S> From<OrdSet<A>> for HashSet<A, S> where
A: Ord + Hash + Eq + Clone,
S: BuildHasher + Default,
impl<'a, A, S> From<&'a OrdSet<A>> for HashSet<A, S> where
A: Ord + Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
impl<'a, A, S> From<&'a OrdSet<A>> for HashSet<A, S> where
A: Ord + Hash + Eq + Clone,
S: BuildHasher + Default,
impl<'a, A, S> IntoIterator for &'a HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
[src]
impl<'a, A, S> IntoIterator for &'a HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
type Item = &'a A
The type of the elements being iterated over.
type IntoIter = Iter<'a, A>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter | [src] |
impl<A, S> IntoIterator for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
[src]
impl<A, S> IntoIterator for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
type Item = A
The type of the elements being iterated over.
type IntoIter = ConsumingIter<Self::Item>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter | [src] |
impl<A, S> Eq for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
impl<A, S> Eq for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
impl<A, S, R> Extend<R> for HashSet<A, S> where
A: Hash + Eq + Clone + From<R>,
S: BuildHasher,
[src]
impl<A, S, R> Extend<R> for HashSet<A, S> where
A: Hash + Eq + Clone + From<R>,
S: BuildHasher,
fn extend<I>(&mut self, iter: I) where | [src] |
impl<A, S> PartialOrd<HashSet<A, S>> for HashSet<A, S> where
A: Hash + Eq + Clone + PartialOrd,
S: BuildHasher + Default,
[src]
impl<A, S> PartialOrd<HashSet<A, S>> for HashSet<A, S> where
A: Hash + Eq + Clone + PartialOrd,
S: BuildHasher + Default,
fn partial_cmp(&self, other: &Self) -> Option<Ordering> | [src] |
| 1.0.0 [src] |
This method tests less than (for self
and other
) and is used by the <
operator. Read more
| 1.0.0 [src] |
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
| 1.0.0 [src] |
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
| 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, S> Default for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
impl<A, S> Default for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
impl<A, S> PartialEq<HashSet<A, S>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
impl<A, S> PartialEq<HashSet<A, S>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
fn eq(&self, other: &Self) -> bool | [src] |
| 1.0.0 [src] |
This method tests for !=
.
impl<A, S> Clone for HashSet<A, S> where
A: Clone,
[src]
impl<A, S> Clone for HashSet<A, S> where
A: Clone,
fn clone(&self) -> Self | [src] |
fn clone_from(&mut self, source: &Self) | 1.0.0 [src] |
Performs copy-assignment from source
. Read more
impl<A, S> Ord for HashSet<A, S> where
A: Hash + Eq + Clone + Ord,
S: BuildHasher + Default,
[src]
impl<A, S> Ord for HashSet<A, S> where
A: Hash + Eq + Clone + Ord,
S: BuildHasher + Default,
fn cmp(&self, other: &Self) -> Ordering | [src] |
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, S> Debug for HashSet<A, S> where
A: Hash + Eq + Clone + Debug,
S: BuildHasher,
[src]
impl<A, S> Debug for HashSet<A, S> where
A: Hash + Eq + Clone + Debug,
S: BuildHasher,
impl<A, S> Debug for HashSet<A, S> where
A: Hash + Eq + Clone + Debug + Ord,
S: BuildHasher,
[src]
impl<A, S> Debug for HashSet<A, S> where
A: Hash + Eq + Clone + Debug + Ord,
S: BuildHasher,
impl<A, S> Hash for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
impl<A, S> Hash for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
fn hash<H>(&self, state: &mut H) where | [src] |
fn hash_slice<H>(data: &[Self], state: &mut H) where | 1.3.0 [src] |
Feeds a slice of this type into the given [Hasher
]. Read more
impl<A, S> Add<HashSet<A, S>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
[src]
impl<A, S> Add<HashSet<A, S>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
type Output = HashSet<A, S>
The resulting type after applying the +
operator.
fn add(self, other: Self) -> Self::Output | [src] |
impl<'a, A, S> Add<&'a HashSet<A, S>> for &'a HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
[src]
impl<'a, A, S> Add<&'a HashSet<A, S>> for &'a HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
type Output = HashSet<A, S>
The resulting type after applying the +
operator.
fn add(self, other: Self) -> Self::Output | [src] |
impl<A, S> Mul<HashSet<A, S>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
[src]
impl<A, S> Mul<HashSet<A, S>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
type Output = HashSet<A, S>
The resulting type after applying the *
operator.
fn mul(self, other: Self) -> Self::Output | [src] |
impl<'a, A, S> Mul<&'a HashSet<A, S>> for &'a HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
[src]
impl<'a, A, S> Mul<&'a HashSet<A, S>> for &'a HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
type Output = HashSet<A, S>
The resulting type after applying the *
operator.
fn mul(self, other: Self) -> Self::Output | [src] |
impl<A, RA, S> FromIterator<RA> for HashSet<A, S> where
A: Hash + Eq + Clone + From<RA>,
S: BuildHasher + Default,
[src]
impl<A, RA, S> FromIterator<RA> for HashSet<A, S> where
A: Hash + Eq + Clone + From<RA>,
S: BuildHasher + Default,
fn from_iter<T>(i: T) -> Self where | [src] |
impl<A, S> Sum<HashSet<A, S>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
impl<A, S> Sum<HashSet<A, S>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
Auto Trait Implementations
impl<A, S> Send for HashSet<A, S> where
A: Send + Sync,
S: Send + Sync,
impl<A, S> Send for HashSet<A, S> where
A: Send + Sync,
S: Send + Sync,
impl<A, S> Sync for HashSet<A, S> where
A: Send + Sync,
S: Send + Sync,
impl<A, S> Sync for HashSet<A, S> where
A: Send + Sync,
S: Send + Sync,
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<I> IntoIterator for I where
I: Iterator,
[src]
impl<I> IntoIterator for I where
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I | [src] |
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> | [src] |
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T | [src] |
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error> | [src] |
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId | [src] |
impl<T> Same for T
[src]
impl<T> Same for T
type Output = T
Should always be Self