[−][src]Struct druid::im::HashSet
An unordered set.
An immutable hash set using [hash array mapped tries] 1.
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, this will be the standard
RandomState
hasher.
Implementations
impl<A> HashSet<A, RandomState>
[src]
#[must_use]pub fn new() -> HashSet<A, RandomState>
[src]
Construct an empty set.
impl<A> HashSet<A, RandomState> where
A: Hash + Eq + Clone,
[src]
A: Hash + Eq + Clone,
#[must_use]pub fn unit(a: A) -> HashSet<A, RandomState>
[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]
#[must_use]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() );
#[must_use]pub fn len(&self) -> usize
[src]
pub fn ptr_eq(&self, other: &HashSet<A, S>) -> bool
[src]
Test whether two sets refer to the same content in memory.
This is true if the two sides are references to the same set, or if the two sets refer to the same root node.
This would return true if you're comparing a set to itself, or if you're comparing a set to a fresh clone of itself.
Time: O(1)
#[must_use]pub fn with_hasher<RS>(hasher: RS) -> HashSet<A, S> where
Arc<S>: From<RS>,
[src]
Arc<S>: From<RS>,
Construct an empty hash set using the provided hasher.
#[must_use]pub fn hasher(&self) -> &Arc<S>
[src]
Get a reference to the set's BuildHasher
.
#[must_use]pub fn new_from<A1>(&self) -> HashSet<A1, S> where
A1: Hash + Eq + Clone,
[src]
A1: Hash + Eq + Clone,
Construct an empty hash set using the same hasher as the current hash set.
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());
#[must_use]pub fn iter(&self) -> Iter<'_, 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.
impl<A, S> HashSet<A, S> where
A: Hash + Eq,
S: BuildHasher,
[src]
A: Hash + Eq,
S: BuildHasher,
#[must_use]pub fn contains<BA>(&self, a: &BA) -> bool where
A: Borrow<BA>,
BA: Hash + Eq + ?Sized,
[src]
A: Borrow<BA>,
BA: Hash + Eq + ?Sized,
Test if a value is part of a set.
Time: O(log n)
#[must_use]pub fn is_subset<RS>(&self, other: RS) -> bool where
RS: Borrow<HashSet<A, S>>,
[src]
RS: Borrow<HashSet<A, S>>,
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)
#[must_use]pub fn is_proper_subset<RS>(&self, other: RS) -> bool where
RS: Borrow<HashSet<A, S>>,
[src]
RS: Borrow<HashSet<A, S>>,
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)
impl<A, S> HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
[src]
A: Hash + Eq + Clone,
S: BuildHasher,
pub fn insert(&mut self, a: A) -> Option<A>
[src]
Insert a value into a set.
Time: O(log n)
pub fn remove<BA>(&mut self, a: &BA) -> Option<A> where
A: Borrow<BA>,
BA: Hash + Eq + ?Sized,
[src]
A: Borrow<BA>,
BA: Hash + Eq + ?Sized,
Remove a value from a set if it exists.
Time: O(log n)
#[must_use]pub fn update(&self, a: A) -> HashSet<A, S>
[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] );
#[must_use]pub fn without<BA>(&self, a: &BA) -> HashSet<A, S> where
A: Borrow<BA>,
BA: Hash + Eq + ?Sized,
[src]
A: Borrow<BA>,
BA: Hash + Eq + ?Sized,
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
F: FnMut(&A) -> bool,
[src]
F: FnMut(&A) -> bool,
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)
Examples
let mut set = hashset![1, 2, 3]; set.retain(|v| *v > 1); let expected = hashset![2, 3]; assert_eq!(expected, set);
#[must_use]pub fn union(self, other: HashSet<A, S>) -> HashSet<A, S>
[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));
#[must_use]pub fn unions<I>(i: I) -> HashSet<A, S> where
I: IntoIterator<Item = HashSet<A, S>>,
S: Default,
[src]
I: IntoIterator<Item = HashSet<A, S>>,
S: Default,
Construct the union of multiple sets.
Time: O(n log n)
#[must_use]pub fn difference(self, other: HashSet<A, S>) -> HashSet<A, S>
[src]
Construct the symmetric difference between two sets.
This is an alias for the
symmetric_difference
method.
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));
#[must_use]pub fn symmetric_difference(self, other: HashSet<A, S>) -> HashSet<A, S>
[src]
Construct the symmetric 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.symmetric_difference(set2));
#[must_use]pub fn relative_complement(self, other: HashSet<A, S>) -> HashSet<A, S>
[src]
Construct the relative complement between two sets, that is the set
of values in self
that do not occur in other
.
Time: O(m log n) where m is the size of the other set
Examples
let set1 = ordset!{1, 2}; let set2 = ordset!{2, 3}; let expected = ordset!{1}; assert_eq!(expected, set1.relative_complement(set2));
#[must_use]pub fn intersection(self, other: HashSet<A, S>) -> HashSet<A, S>
[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));
Trait Implementations
impl<'a, A, S> Add<&'a HashSet<A, S>> for &'a HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
[src]
A: Hash + Eq + Clone,
S: BuildHasher,
type Output = HashSet<A, S>
The resulting type after applying the +
operator.
pub fn add(
self,
other: &'a HashSet<A, S>
) -> <&'a HashSet<A, S> as Add<&'a HashSet<A, S>>>::Output
[src]
self,
other: &'a HashSet<A, S>
) -> <&'a HashSet<A, S> as Add<&'a HashSet<A, S>>>::Output
impl<A, S> Add<HashSet<A, S>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
[src]
A: Hash + Eq + Clone,
S: BuildHasher,
type Output = HashSet<A, S>
The resulting type after applying the +
operator.
pub fn add(
self,
other: HashSet<A, S>
) -> <HashSet<A, S> as Add<HashSet<A, S>>>::Output
[src]
self,
other: HashSet<A, S>
) -> <HashSet<A, S> as Add<HashSet<A, S>>>::Output
impl<A, S> Clone for HashSet<A, S> where
A: Clone,
[src]
A: Clone,
pub fn clone(&self) -> HashSet<A, S>
[src]
Clone a set.
Time: O(1)
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Data> Data for HashSet<T>
[src]
impl<A, S> Debug for HashSet<A, S> where
A: Hash + Eq + Debug,
S: BuildHasher,
[src]
A: Hash + Eq + Debug,
S: BuildHasher,
impl<A, S> Debug for HashSet<A, S> where
A: Hash + Eq + Debug + Ord,
S: BuildHasher,
[src]
A: Hash + Eq + Debug + Ord,
S: BuildHasher,
impl<A, S> Default for HashSet<A, S> where
S: BuildHasher + Default,
[src]
S: BuildHasher + Default,
impl<A, S> Eq for HashSet<A, S> where
A: Hash + Eq,
S: BuildHasher + Default,
[src]
A: Hash + Eq,
S: BuildHasher + Default,
impl<A, S, R> Extend<R> for HashSet<A, S> where
A: Hash + Eq + Clone + From<R>,
S: BuildHasher,
[src]
A: Hash + Eq + Clone + From<R>,
S: BuildHasher,
pub fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = R>,
[src]
I: IntoIterator<Item = R>,
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl<'a, A, S> From<&'a [A]> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
A: Hash + Eq + 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]
A: Hash + Eq + 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]
A: Eq + Hash + Clone,
S: BuildHasher + Default,
pub fn from(hash_set: &HashSet<A, RandomState>) -> HashSet<A, S>
[src]
impl<'a, A, S> From<&'a HashSet<A, S>> for OrdSet<A> where
A: Clone + Eq + Ord + Hash,
S: BuildHasher,
[src]
A: Clone + Eq + Ord + Hash,
S: BuildHasher,
impl<'a, A, S> From<&'a OrdSet<A>> for HashSet<A, S> where
A: Ord + Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
A: Ord + Hash + Eq + Clone,
S: BuildHasher + Default,
impl<'a, A, S> From<&'a Vec<A, Global>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
A: Hash + Eq + Clone,
S: BuildHasher + Default,
impl<'s, 'a, A, OA, SA, SB> From<&'s HashSet<&'a A, SA>> for HashSet<OA, SB> where
A: ToOwned<Owned = OA> + Hash + Eq + ?Sized,
OA: Borrow<A> + Hash + Eq + Clone,
SB: BuildHasher + Default,
SA: BuildHasher,
[src]
A: ToOwned<Owned = OA> + Hash + Eq + ?Sized,
OA: Borrow<A> + Hash + Eq + Clone,
SB: BuildHasher + Default,
SA: BuildHasher,
impl<A, S> From<HashSet<A, RandomState>> for HashSet<A, S> where
A: Eq + Hash + Clone,
S: BuildHasher + Default,
[src]
A: Eq + Hash + Clone,
S: BuildHasher + Default,
pub fn from(hash_set: HashSet<A, RandomState>) -> HashSet<A, S>
[src]
impl<A, S> From<HashSet<A, S>> for OrdSet<A> where
A: Clone + Eq + Ord + Hash,
S: BuildHasher,
[src]
A: Clone + Eq + Ord + Hash,
S: BuildHasher,
impl<A, S> From<OrdSet<A>> for HashSet<A, S> where
A: Ord + Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
A: Ord + Hash + Eq + Clone,
S: BuildHasher + Default,
impl<A, S> From<Vec<A, Global>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
A: Hash + Eq + Clone,
S: BuildHasher + Default,
impl<A, RA, S> FromIterator<RA> for HashSet<A, S> where
A: Hash + Eq + Clone + From<RA>,
S: BuildHasher + Default,
[src]
A: Hash + Eq + Clone + From<RA>,
S: BuildHasher + Default,
pub fn from_iter<T>(i: T) -> HashSet<A, S> where
T: IntoIterator<Item = RA>,
[src]
T: IntoIterator<Item = RA>,
impl<A, S> Hash for HashSet<A, S> where
A: Hash + Eq,
S: BuildHasher + Default,
[src]
A: Hash + Eq,
S: BuildHasher + Default,
pub fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<A, S> IntoIterator for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
[src]
A: Hash + Eq + Clone,
S: BuildHasher,
type Item = A
The type of the elements being iterated over.
type IntoIter = ConsumingIter<<HashSet<A, S> as IntoIterator>::Item>
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> <HashSet<A, S> as IntoIterator>::IntoIter
[src]
impl<'a, A, S> IntoIterator for &'a HashSet<A, S> where
A: Hash + Eq,
S: BuildHasher,
[src]
A: Hash + Eq,
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?
pub fn into_iter(self) -> <&'a HashSet<A, S> as IntoIterator>::IntoIter
[src]
impl<'a, A, S> Mul<&'a HashSet<A, S>> for &'a HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
[src]
A: Hash + Eq + Clone,
S: BuildHasher,
type Output = HashSet<A, S>
The resulting type after applying the *
operator.
pub fn mul(
self,
other: &'a HashSet<A, S>
) -> <&'a HashSet<A, S> as Mul<&'a HashSet<A, S>>>::Output
[src]
self,
other: &'a HashSet<A, S>
) -> <&'a HashSet<A, S> as Mul<&'a HashSet<A, S>>>::Output
impl<A, S> Mul<HashSet<A, S>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher,
[src]
A: Hash + Eq + Clone,
S: BuildHasher,
type Output = HashSet<A, S>
The resulting type after applying the *
operator.
pub fn mul(
self,
other: HashSet<A, S>
) -> <HashSet<A, S> as Mul<HashSet<A, S>>>::Output
[src]
self,
other: HashSet<A, S>
) -> <HashSet<A, S> as Mul<HashSet<A, S>>>::Output
impl<A, S> Ord for HashSet<A, S> where
A: Hash + Eq + Clone + Ord,
S: BuildHasher + Default,
[src]
A: Hash + Eq + Clone + Ord,
S: BuildHasher + Default,
pub fn cmp(&self, other: &HashSet<A, S>) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<A, S> PartialEq<HashSet<A, S>> for HashSet<A, S> where
A: Hash + Eq,
S: BuildHasher + Default,
[src]
A: Hash + Eq,
S: BuildHasher + Default,
pub fn eq(&self, other: &HashSet<A, S>) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<A, S> PartialOrd<HashSet<A, S>> for HashSet<A, S> where
A: Hash + Eq + Clone + PartialOrd<A>,
S: BuildHasher + Default,
[src]
A: Hash + Eq + Clone + PartialOrd<A>,
S: BuildHasher + Default,
pub fn partial_cmp(&self, other: &HashSet<A, S>) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<A, S> Sum<HashSet<A, S>> for HashSet<A, S> where
A: Hash + Eq + Clone,
S: BuildHasher + Default,
[src]
A: Hash + Eq + Clone,
S: BuildHasher + Default,
Auto Trait Implementations
impl<A, S> RefUnwindSafe for HashSet<A, S> where
A: RefUnwindSafe,
S: RefUnwindSafe,
[src]
A: RefUnwindSafe,
S: RefUnwindSafe,
impl<A, S> Send for HashSet<A, S> where
A: Send + Sync,
S: Send + Sync,
[src]
A: Send + Sync,
S: Send + Sync,
impl<A, S> Sync for HashSet<A, S> where
A: Send + Sync,
S: Send + Sync,
[src]
A: Send + Sync,
S: Send + Sync,
impl<A, S> Unpin for HashSet<A, S> where
A: Unpin,
[src]
A: Unpin,
impl<A, S> UnwindSafe for HashSet<A, S> where
A: RefUnwindSafe + UnwindSafe,
S: RefUnwindSafe,
[src]
A: RefUnwindSafe + UnwindSafe,
S: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> AnyEq for T where
T: PartialEq<T> + Any,
[src]
T: PartialEq<T> + Any,
pub fn equals(&self, other: &(dyn Any + 'static)) -> bool
[src]
pub fn as_any(&self) -> &(dyn Any + 'static)
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> RoundFrom<T> for T
pub fn round_from(x: T) -> T
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>,
U: RoundFrom<T>,
pub fn round_into(self) -> U
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,