Struct im::ordset::OrdSet [] [src]

pub struct OrdSet<A>(_);

Ordered Set

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

Methods

impl<A> OrdSet<A>
[src]

[src]

Construct an empty set.

[src]

Construct a set with a single value.

Examples

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

Important traits for Iter<A>
[src]

[src]

Test whether a set is empty.

Time: O(1)

Examples

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

[src]

Get the size of a set.

Time: O(1)

Examples

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

[src]

Get the smallest value in a set.

If the set is empty, returns None.

[src]

Get the largest value in a set.

If the set is empty, returns None.

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

[src]

Insert a value into a set.

Time: O(log n)

Examples

let set = ordset![456];
assert_eq!(
  set.insert(123),
  ordset![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)

Examples

let mut set = ordset!{};
set.insert_mut(123);
set.insert_mut(456);
assert_eq!(
  set,
  ordset![123, 456]
);

[src]

Test if a value is part of a set.

Time: O(log n)

[src]

Remove a value from a set.

Time: O(log n)

[src]

Remove a value from 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]

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]

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.

[src]

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.

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

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

Trait Implementations

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

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<A: Ord + PartialEq> PartialEq for OrdSet<A>
[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: Ord + Eq> Eq for OrdSet<A>
[src]

impl<A: Ord> PartialOrd for OrdSet<A>
[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: Ord> Ord for OrdSet<A>
[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: Ord + Hash> Hash for OrdSet<A>
[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> Default for OrdSet<A>
[src]

[src]

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

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

The resulting type after applying the + operator.

[src]

Performs the + operation.

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

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<A: Ord + Debug> Debug for OrdSet<A>
[src]

[src]

Formats the value using the given formatter. Read more

impl<A: Ord, RA> FromIterator<RA> for OrdSet<A> where
    RA: Shared<A>, 
[src]

[src]

Creates a value from an iterator. Read more

impl<'a, A> IntoIterator for &'a OrdSet<A> where
    A: Ord
[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> IntoIterator for OrdSet<A> where
    A: Ord
[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, A: Ord + Clone> From<&'a [A]> for OrdSet<A>
[src]

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

impl<A: Ord, S> From<HashSet<A, S>> for OrdSet<A>
[src]

[src]

Performs the conversion.

impl<'a, A: Ord, S> From<&'a HashSet<A, S>> for OrdSet<A>
[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> Send for OrdSet<A> where
    A: Send + Sync

impl<A> Sync for OrdSet<A> where
    A: Send + Sync