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]

[src]

Construct an empty set.

[src]

Construct a set with a single value.

Examples

let set = HashSet::singleton(123);
assert!(set.contains(&123));

impl<A, S> HashSet<A, S>
[src]

[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]

Get the size of a set.

Time: O(1)

Examples

assert_eq!(3, hashset![1, 2, 3].len());

impl<A, S> HashSet<A, S> where
    A: Hash + Eq,
    S: BuildHasher
[src]

[src]

Construct an empty hash set using the provided hasher.

[src]

Construct an empty hash set using the same hasher as the current hash set.

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

[src]

Insert a value into a set.

Time: O(log n)

Examples

let set = hashset![123];
assert_eq!(
  set.insert(456),
  hashset![123, 456]
);

[src]

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)

[src]

Test if a value is part of a set.

Time: O(log n)

[src]

Remove a value from a set if it exists.

Time: O(log n)

[src]

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)

[src]

Construct the union of two sets.

[src]

Construct the union of multiple sets.

[src]

Construct the difference between two sets.

[src]

Construct the intersection of two sets.

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

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

Trait Implementations

impl<A: Hash + Eq + Ord, S: BuildHasher> From<HashSet<A, S>> for OrdSet<A>
[src]

[src]

Performs the conversion.

impl<'a, A: Hash + Eq + Ord, S: BuildHasher> From<&'a HashSet<A, S>> for OrdSet<A>
[src]

[src]

Performs the conversion.

impl<A, S> Clone for HashSet<A, S>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<A: Hash + Eq, S: BuildHasher + Default> PartialEq for HashSet<A, S>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

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]

[src]

This method returns an ordering between self and other values if one exists. Read more

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: Hash + Eq + Ord, S: BuildHasher + Default> Ord for HashSet<A, S>
[src]

[src]

This method returns an Ordering between self and other. Read more

1.21.0
[src]

Compares and returns the maximum of two values. Read more

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]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

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]

[src]

Returns the "default value" for a type. Read more

impl<A: Hash + Eq, S: BuildHasher> Add for HashSet<A, S>
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<A: Hash + Eq, S: BuildHasher> Mul for HashSet<A, S>
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<'a, A: Hash + Eq, S: BuildHasher> Add for &'a HashSet<A, S>
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<'a, A: Hash + Eq, S: BuildHasher> Mul for &'a HashSet<A, S>
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<A, S> Sum for HashSet<A, S> where
    A: Hash + Eq,
    S: BuildHasher + Default
[src]

[src]

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]

[src]

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]

[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]

[src]

Creates a value from an iterator. Read more

impl<'a, A: Hash + Eq, S: BuildHasher> IntoIterator for &'a HashSet<A, S>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more

impl<A: Hash + Eq, S: BuildHasher> IntoIterator for HashSet<A, S>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[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]

[src]

Performs the conversion.

impl<'a, A: Hash + Eq + Clone, S: BuildHasher + Default> From<&'a [A]> for HashSet<A, S>
[src]

[src]

Performs the conversion.

impl<'a, A: Hash + Eq, S: BuildHasher + Default> From<&'a [Arc<A>]> for HashSet<A, S>
[src]

[src]

Performs the conversion.

impl<A: Hash + Eq, S: BuildHasher + Default> From<Vec<A>> for HashSet<A, S>
[src]

[src]

Performs the conversion.

impl<'a, A: Hash + Eq + Clone, S: BuildHasher + Default> From<&'a Vec<A>> for HashSet<A, S>
[src]

[src]

Performs the conversion.

impl<'a, A: Hash + Eq, S: BuildHasher + Default> From<&'a Vec<Arc<A>>> for HashSet<A, S>
[src]

[src]

Performs the conversion.

impl<A: Eq + Hash, S: BuildHasher + Default> From<HashSet<A>> for HashSet<A, S>
[src]

[src]

Performs the conversion.

impl<'a, A: Eq + Hash + Clone, S: BuildHasher + Default> From<&'a HashSet<A>> for HashSet<A, S>
[src]

[src]

Performs the conversion.

impl<'a, A: Eq + Hash, S: BuildHasher + Default> From<&'a HashSet<Arc<A>>> for HashSet<A, S>
[src]

[src]

Performs the conversion.

impl<A: Hash + Eq, S: BuildHasher + Default> From<BTreeSet<A>> for HashSet<A, S>
[src]

[src]

Performs the conversion.

impl<'a, A: Hash + Eq + Clone, S: BuildHasher + Default> From<&'a BTreeSet<A>> for HashSet<A, S>
[src]

[src]

Performs the conversion.

impl<'a, A: Hash + Eq, S: BuildHasher + Default> From<&'a BTreeSet<Arc<A>>> for HashSet<A, S>
[src]

[src]

Performs the conversion.

impl<A: Ord + Hash + Eq, S: BuildHasher + Default> From<OrdSet<A>> for HashSet<A, S>
[src]

[src]

Performs the conversion.

impl<'a, A: Ord + Hash + Eq, S: BuildHasher + Default> From<&'a OrdSet<A>> for HashSet<A, S>
[src]

[src]

Performs the conversion.

Auto Trait Implementations

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