Struct im::set::Set [] [src]

pub struct Set<A>(_);

Ordered Set

An immutable ordered set implemented as a balanced 2-3 tree.

This is implemented as a Map with no values, so it shares the exact performance characteristics of Map.

Methods

impl<A> Set<A>
[src]

Construct an empty set.

Construct a set with a single value.

Examples

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

Test whether a set is empty.

Time: O(1)

Examples

assert!(
  !set![1, 2, 3].is_empty()
);
assert!(
  Set::<i32>::new().is_empty()
);

Get the size of a set.

Time: O(1)

Examples

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

Get the smallest value in a set.

If the set is empty, returns None.

Get the largest value in a set.

If the set is empty, returns None.

impl<A: Ord> Set<A>
[src]

Insert a value into a set.

Time: O(log n)

Examples

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

Test if a value is part of a set.

Time: O(log n)

Remove a value from a set.

Construct the union of two sets.

Construct the union of multiple sets.

Construct the difference between two sets.

Construct the intersection of two sets.

Split a set into two, with the left hand set containing values which are smaller than split, and the right hand set containing values which are larger than split.

The split value itself is discarded.

Split a set into two, with the left hand set containing values which are smaller than split, and the right hand set containing values which are larger than split.

Returns a tuple of the two maps and a boolean which is true if the split value existed in the original set, and false otherwise.

Test whether a set is a subset of another set, meaning that all values in our set must also be in the other set.

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.

Construct a set with only the n smallest values from a given set.

Construct a set with the n smallest values removed from a given set.

Remove the smallest value from a set, and return that value as well as the updated set.

Remove the largest value from a set, and return that value as well as the updated set.

Discard the smallest value from a set, returning the updated set.

Discard the largest value from a set, returning the updated set.

Trait Implementations

impl<A> Clone for Set<A>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<A: PartialEq> PartialEq for Set<A>
[src]

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

This method tests for !=.

impl<A: Eq> Eq for Set<A>
[src]

impl<A: PartialOrd> PartialOrd for Set<A>
[src]

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

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<A: Ord> Ord for Set<A>
[src]

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

impl<A: Hash> Hash for Set<A>
[src]

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

Feeds a slice of this type into the given [Hasher]. Read more

impl<A> Default for Set<A>
[src]

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

impl<'a, A: Ord> Add for &'a Set<A>
[src]

The resulting type after applying the + operator

The method for the + operator

impl<'a, A: Ord> Mul for &'a Set<A>
[src]

The resulting type after applying the * operator

The method for the * operator

impl<A: Debug> Debug for Set<A>
[src]

Formats the value using the given formatter.

impl<A: Ord, RA> FromIterator<RA> for Set<A> where
    Arc<A>: From<RA>, 
[src]

Creates a value from an iterator. Read more

impl<'a, A> IntoIterator for &'a Set<A>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

impl<A> IntoIterator for Set<A>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

impl<'a, A: Ord + Clone> From<&'a [A]> for Set<A>
[src]

Performs the conversion.

impl<'a, A: Ord> From<&'a [Arc<A>]> for Set<A>
[src]

Performs the conversion.

impl<A: Ord> From<Vec<A>> for Set<A>
[src]

Performs the conversion.

impl<'a, A: Ord + Clone> From<&'a Vec<A>> for Set<A>
[src]

Performs the conversion.

impl<'a, A: Ord> From<&'a Vec<Arc<A>>> for Set<A>
[src]

Performs the conversion.

impl<A: Eq + Hash + Ord> From<HashSet<A>> for Set<A>
[src]

Performs the conversion.

impl<'a, A: Eq + Hash + Ord + Clone> From<&'a HashSet<A>> for Set<A>
[src]

Performs the conversion.

impl<'a, A: Eq + Hash + Ord> From<&'a HashSet<Arc<A>>> for Set<A>
[src]

Performs the conversion.

impl<A: Ord> From<BTreeSet<A>> for Set<A>
[src]

Performs the conversion.

impl<'a, A: Ord + Clone> From<&'a BTreeSet<A>> for Set<A>
[src]

Performs the conversion.

impl<'a, A: Ord> From<&'a BTreeSet<Arc<A>>> for Set<A>
[src]

Performs the conversion.