Struct im::ordset::OrdSet
[−]
[src]
pub struct OrdSet<A> { /* fields omitted */ }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]
pub fn new() -> Self[src]
Construct an empty set.
pub fn singleton<R>(a: R) -> Self where
R: Shared<A>, [src]
R: Shared<A>,
Construct a set with a single value.
Examples
let set = OrdSet::singleton(123); assert!(set.contains(&123));
pub fn is_empty(&self) -> bool[src]
Test whether a set is empty.
Time: O(1)
Examples
assert!( !ordset![1, 2, 3].is_empty() ); assert!( OrdSet::<i32>::new().is_empty() );
pub fn len(&self) -> usize[src]
pub fn get_min(&self) -> Option<Arc<A>>[src]
Get the smallest value in a set.
If the set is empty, returns None.
pub fn get_max(&self) -> Option<Arc<A>>[src]
Get the largest value in a set.
If the set is empty, returns None.
impl<A: Ord> OrdSet<A>[src]
pub fn iter(&self) -> Iter<Arc<A>>[src]
pub fn insert<R>(&self, a: R) -> Self where
R: Shared<A>, [src]
R: Shared<A>,
Insert a value into a set.
Time: O(log n)
Examples
let set = ordset![456]; assert_eq!( set.insert(123), ordset![123, 456] );
pub fn insert_mut<R>(&mut self, a: R) where
R: Shared<A>, [src]
R: Shared<A>,
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] );
pub fn contains(&self, a: &A) -> bool[src]
Test if a value is part of a set.
Time: O(log n)
pub fn remove(&self, a: &A) -> Self[src]
Remove a value from a set.
Time: O(log n)
pub fn remove_mut<R>(&mut self, a: &A)[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)
pub fn union<RS>(&self, other: RS) -> Self where
RS: Borrow<Self>, [src]
RS: Borrow<Self>,
Construct the union of two sets.
pub fn unions<I>(i: I) -> Self where
I: IntoIterator<Item = Self>, [src]
I: IntoIterator<Item = Self>,
Construct the union of multiple sets.
pub fn difference<RS>(&self, other: RS) -> Self where
RS: Borrow<Self>, [src]
RS: Borrow<Self>,
Construct the difference between two sets.
pub fn intersection<RS>(&self, other: RS) -> Self where
RS: Borrow<Self>, [src]
RS: Borrow<Self>,
Construct the intersection of two sets.
pub fn split(&self, split: &A) -> (Self, Self)[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.
pub fn split_member(&self, split: &A) -> (Self, bool, Self)[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.
pub fn is_subset<RS>(&self, other: RS) -> bool where
RS: Borrow<Self>, [src]
RS: Borrow<Self>,
Test whether a set is a subset of another set, meaning that all values in our set must also be in the other set.
pub fn is_proper_subset<RS>(&self, other: RS) -> bool where
RS: Borrow<Self>, [src]
RS: Borrow<Self>,
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.
pub fn take(&self, n: usize) -> Self[src]
Construct a set with only the n smallest values from a given
set.
pub fn skip(&self, n: usize) -> Self[src]
Construct a set with the n smallest values removed from a
given set.
pub fn pop_min(&self) -> (Option<Arc<A>>, Self)[src]
Remove the smallest value from a set, and return that value as well as the updated set.
pub fn pop_max(&self) -> (Option<Arc<A>>, Self)[src]
Remove the largest value from a set, and return that value as well as the updated set.
pub fn remove_min(&self) -> Self[src]
Discard the smallest value from a set, returning the updated set.
pub fn remove_max(&self) -> Self[src]
Discard the largest value from a set, returning the updated set.
Trait Implementations
impl<A> Clone for OrdSet<A>[src]
fn clone(&self) -> Self[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl<A: Ord> PartialEq for OrdSet<A>[src]
fn eq(&self, other: &Self) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl<A: Ord + Eq> Eq for OrdSet<A>[src]
impl<A: Ord> PartialOrd for OrdSet<A>[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>[src]
This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &Rhs) -> bool1.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]
fn cmp(&self, other: &Self) -> Ordering[src]
This method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
Compares and returns the minimum of two values. Read more
impl<A: Ord + Hash> Hash for OrdSet<A>[src]
fn hash<H>(&self, state: &mut H) where
H: Hasher, [src]
H: Hasher,
Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher]. Read more
impl<A> Default for OrdSet<A>[src]
impl<A: Ord> Add for OrdSet<A>[src]
type Output = OrdSet<A>
The resulting type after applying the + operator.
fn add(self, other: Self) -> Self::Output[src]
Performs the + operation.
impl<'a, A: Ord> Add for &'a OrdSet<A>[src]
type Output = OrdSet<A>
The resulting type after applying the + operator.
fn add(self, other: Self) -> Self::Output[src]
Performs the + operation.
impl<A: Ord> Mul for OrdSet<A>[src]
type Output = OrdSet<A>
The resulting type after applying the * operator.
fn mul(self, other: Self) -> Self::Output[src]
Performs the * operation.
impl<'a, A: Ord> Mul for &'a OrdSet<A>[src]
type Output = OrdSet<A>
The resulting type after applying the * operator.
fn mul(self, other: Self) -> Self::Output[src]
Performs the * operation.
impl<A: Ord> Sum for OrdSet<A>[src]
fn sum<I>(it: I) -> Self where
I: Iterator<Item = Self>, [src]
I: Iterator<Item = Self>,
Method which takes an iterator and generates Self from the elements by "summing up" the items. Read more
impl<A, R> Extend<R> for OrdSet<A> where
A: Ord,
R: Shared<A>, [src]
A: Ord,
R: Shared<A>,
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = R>, [src]
I: IntoIterator<Item = R>,
Extends a collection with the contents of an iterator. Read more
impl<A: Ord + Debug> Debug for OrdSet<A>[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]
Formats the value using the given formatter. Read more
impl<A: Ord, RA> FromIterator<RA> for OrdSet<A> where
RA: Shared<A>, [src]
RA: Shared<A>,
fn from_iter<T>(i: T) -> Self where
T: IntoIterator<Item = RA>, [src]
T: IntoIterator<Item = RA>,
Creates a value from an iterator. Read more
impl<'a, A> IntoIterator for &'a OrdSet<A> where
A: Ord, [src]
A: Ord,
type Item = Arc<A>
The type of the elements being iterated over.
type IntoIter = Iter<Arc<A>>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter[src]
Creates an iterator from a value. Read more
impl<A> IntoIterator for OrdSet<A> where
A: Ord, [src]
A: Ord,
type Item = Arc<A>
The type of the elements being iterated over.
type IntoIter = Iter<Arc<A>>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter[src]
Creates an iterator from a value. Read more