[][src]Struct normalize_interval::selection::Selection

pub struct Selection<T>(_);

A possibly noncontiguous collection of Intervals of the type T.

Implementations

impl<T> Selection<T> where
    T: Ord + Clone,
    RawInterval<T>: Normalize
[src]

pub fn new() -> Self[src]

Constructs a new empty Selection.

Examples

let sel: Selection<i32> = Selection::new();

pub fn empty() -> Self[src]

Constructs a new empty Selection.

pub fn full() -> Self[src]

Constructs a new full Selection.

Examples

let sel: Selection<i32> = Selection::full();

 

pub fn lower_bound(&self) -> Option<Bound<T>>[src]

Returns the lower Bound of the Selection, or None if the Selection is empty.

Examples

let sel: Selection<i32> = Selection::from(Interval::closed(-3, 5));
assert_eq!(sel.lower_bound(), Some(Include(-3)));

Finite types will have their bounds closed:

let sel: Selection<i32> = Selection::from(Interval::open(-3, 5));
 
assert_eq!(sel.lower_bound(), Some(Include(-2)));

pub fn upper_bound(&self) -> Option<Bound<T>>[src]

Returns the upper Bound of the Selection, or None if the Selection is empty.

Examples

let sel: Selection<i32> = Selection::from(Interval::closed(-3, 5));
assert_eq!(sel.upper_bound(), Some(Include(5)));

Finite types will have their bounds closed:

let sel: Selection<i32> = Selection::from(Interval::open(-3, 5));
 
assert_eq!(sel.upper_bound(), Some(Include(4)));

pub fn infimum(&self) -> Option<T>[src]

Returns the greatest lower bound of the Selection, or None if the Selection is empty.

Examples

let sel: Selection<i32> = Selection::from(Interval::open(-3, 5));
assert_eq!(sel.infimum(), Some(-3));

Finite types will have their bounds closed:

let sel: Selection<i32> = Selection::from(Interval::open(-3, 5));
 
assert_eq!(sel.infimum(), Some(-3));

pub fn supremum(&self) -> Option<T>[src]

Returns the least upper bound of the Interval, or None if the Interval is empty.

Examples

let sel: Selection<i32> = Selection::from(Interval::open(-3, 5));
assert_eq!(sel.supremum(), Some(5));

Finite types will have their bounds closed:

let sel: Selection<i32> = Selection::from(Interval::open(-3, 5));
 
assert_eq!(sel.supremum(), Some(5));

pub fn is_empty(&self) -> bool[src]

Returns true if the interval contains no points.

Example

let sel: Selection<i32> = Selection::from(Interval::closed(-3, 5));
assert_eq!(sel.is_empty(), false);

let sel: Selection<i32> = Selection::from(Interval::empty());
assert_eq!(sel.is_empty(), true);

pub fn is_full(&self) -> bool[src]

Returns true if the interval contains all points.

Example

let sel: Selection<i32> = Selection::from(Interval::closed(-3, 5));
assert_eq!(sel.is_full(), false);

let sel: Selection<i32> = Selection::from(Interval::full());
assert_eq!(sel.is_full(), true);

pub fn is_bounded(&self) -> bool[src]

Returns true if the the interval is bounded.

Example

let sel: Interval<i32> = Interval::open(-2, 4);
assert_eq!(sel.is_left_bounded(), true);

let sel: Interval<i32> = Interval::unbounded_to(-3);
assert_eq!(sel.is_left_bounded(), true);

pub fn is_left_bounded(&self) -> bool[src]

Returns true if the the Selection is left-bounded.

Example

let sel: Selection<i32> = Interval::open(-2, 4).into();
assert_eq!(sel.is_left_bounded(), true);

let sel: Selection<i32> = Interval::unbounded_to(-3).into();
assert_eq!(sel.is_left_bounded(), true);

pub fn is_right_bounded(&self) -> bool[src]

Returns true if the the Selection is right-bounded.

Example

let sel: Selection<i32> = Interval::open(-2, 4).into();
assert_eq!(sel.is_right_bounded(), true);

let sel: Selection<i32> = Interval::unbounded_from(-3).into();
assert_eq!(sel.is_right_bounded(), true);

pub fn is_half_bounded(&self) -> bool[src]

Returns true if the the Selection is helf-bounded.

Example

let sel: Selection<i32> = Interval::unbounded_to(-2).into();
assert_eq!(sel.is_half_bounded(), false);

let sel: Selection<i32> = Interval::full().into();
assert_eq!(sel.is_half_bounded(), false);

pub fn contains(&self, point: &T) -> bool[src]

Returns true if the the Selection contains the given point.

Example

let sel: Selection<i32> = Selection::from(Interval::closed(0, 20));
assert_eq!(sel.contains(&2), true);

assert_eq!(sel.contains(&-15), false);

pub fn intersects(&self, other: &Self) -> bool[src]

Returns true if the Selection overlaps the given Selection.

Example

let a: Selection<i32> = Selection::from(Interval::closed(-3, 5));
let b: Selection<i32> = Selection::from(Interval::closed(4, 15));
assert_eq!(a.intersects(&b), true);

let a: Selection<i32> = Selection::from(Interval::closed(-3, 5));
let b: Selection<i32> = Selection::from(Interval::closed(8, 12));
assert_eq!(a.intersects(&b), false);

pub fn complement(&self) -> Self[src]

Returns the Selection containing all points in not contained in the Selection.

Example

Finite types will have their bounds closed:

let sel: Selection<i32> = Selection::from(Interval::closed(-3, 5));
 
assert_eq!(sel.complement().iter().collect::<Vec<_>>(), vec![
    Interval::closed(i32::MIN, -4),
    Interval::closed(6, i32::MAX),
]);

pub fn intersect(&self, other: &Self) -> Self[src]

Returns the Selection containing all points in both the given Selections.

Example

let a: Selection<i32> = Selection::from(Interval::closed(-3, 7));
let b: Selection<i32> = Selection::from(Interval::closed(4, 13));
assert_eq!(a.intersect(&b).iter().collect::<Vec<_>>(),
    vec![Interval::closed(4, 7)]);

Finite types will have their bounds closed:

let a: Selection<i32> = Selection::from(Interval::open(-3, 7));
let b: Selection<i32> = Selection::from(Interval::open(4, 13));
assert_eq!(a.intersect(&b).iter().collect::<Vec<_>>(),
    vec![Interval::closed(5, 6)]);

pub fn union(&self, other: &Self) -> Self[src]

Returns the Selection containing all points in either of the given Selections.

Example

let a: Selection<i32> = Selection::from(Interval::closed(-3, 7));
let b: Selection<i32> = Selection::from(Interval::closed(4, 13));
assert_eq!(a.union(&b).iter().collect::<Vec<_>>(),
    vec![Interval::closed(-3, 13)]);

Finite types will have their bounds closed:

let a: Selection<i32> = Selection::from(Interval::open(-3, 7));
let b: Selection<i32> = Selection::from(Interval::open(4, 13));
assert_eq!(a.union(&b).iter().collect::<Vec<_>>(),
    vec![Interval::closed(-2, 12)]);

pub fn minus(&self, other: &Self) -> Self[src]

Returns the Selection containing all points in the Selection which are not in the given Selections.

Example

let a: Selection<i32> = Selection::from(Interval::closed(-3, 7));
let b: Selection<i32> = Selection::from(Interval::closed(4, 13));
assert_eq!(a.minus(&b).iter().collect::<Vec<_>>(),
    vec![Interval::right_open(-3, 4)]);

pub fn enclose(&self) -> Interval<T>[src]

Returns the smallest Interval containing all of the points in the Selection.

Example

let a: Selection<i32> = Selection::from(Interval::open(-3, 5));
let b: Selection<i32> = Selection::from(Interval::closed(9, 13));
let sel = a.union(&b);

assert_eq!(sel.enclose(), Interval::left_open(-3, 13));

pub fn closure(&self) -> Interval<T>[src]

Returns the smallest closed Interval containing all of the points in the Selection.

Example

let a: Selection<i32> = Selection::from(Interval::open(-3, 5));
let b: Selection<i32> = Selection::from(Interval::closed(9, 13));
let sel = a.union(&b);

assert_eq!(sel.enclose(), Interval::closed(-2, 13));

pub fn intersect_in_place(&mut self, interval: Interval<T>)[src]

Reduces the Selection to only those points contained in the given Interval.

Example

let mut sel: Selection<i32> = Selection::from(Interval::closed(-3, 7));
sel.intersect_in_place(Interval::open(2, 5));

assert_eq!(sel.iter().collect::<Vec<_>>(),
    [Interval::open(2, 5)]);

Finite types will have their bounds closed:

let mut sel: Selection<i32> = Selection::from(Interval::closed(-3, 7));
sel.intersect_in_place(Interval::open(2, 5));

assert_eq!(sel.iter().collect::<Vec<_>>(),
    [Interval::closed(3, 4)]);

pub fn union_in_place(&mut self, interval: Interval<T>)[src]

Adds all of the points in the given Interval to the Selection.

Example

let mut sel: Selection<i32> = Selection::from(Interval::closed(-3, 7));
sel.union_in_place(Interval::open(12, 15));

assert_eq!(sel.iter().collect::<Vec<_>>(),
    [Interval::closed(-3, 7), Interval::open(12, 15)]);

Finite types will have their bounds closed:

let mut sel: Selection<i32> = Selection::from(Interval::open(-3, 8));
sel.union_in_place(Interval::open(7, 10));

assert_eq!(sel.iter().collect::<Vec<_>>(),
    [Interval::closed(-2, 9)]);

pub fn minus_in_place(&mut self, interval: Interval<T>)[src]

Removes all of the points in the given Interval from the Selection.

Example

let mut sel: Selection<i32> = Selection::from(Interval::closed(-3, 7));
sel.minus_in_place(Interval::open(2, 5));

assert_eq!(sel.iter().collect::<Vec<_>>(),
    [Interval::closed(-3, 2), Interval::closed(5, 7)]);

Finite types will have their bounds closed:

let mut sel: Selection<i32> = Selection::from(Interval::closed(-3, 7));
sel.minus_in_place(Interval::closed(2, 5));

assert_eq!(sel.iter().collect::<Vec<_>>(),
    [Interval::closed(-3, 1), Interval::closed(6, 7)]);

pub fn interval_iter(&self) -> IntervalIter<T>

Important traits for IntervalIter<'t, T>

impl<'t, T> Iterator for IntervalIter<'t, T> where
    T: Ord + Clone,
    RawInterval<T>: Normalize
type Item = Interval<T>;
[src]

Returns an iterator over each of the Intervals in the Selection.

pub fn into_interval_iter(self) -> IntoIntervalIter<T>

Important traits for IntoIntervalIter<T>

impl<T> Iterator for IntoIntervalIter<T> where
    T: Ord + Clone,
    RawInterval<T>: Normalize
type Item = Interval<T>;
[src]

Returns an iterator over each of the Intervals in the Selection.

impl<T> Selection<T> where
    T: Ord + Clone + Finite
[src]

pub fn iter(&self) -> Iter<T>

Important traits for Iter<'t, T>

impl<'t, T> Iterator for Iter<'t, T> where
    T: Ord + Clone + Finite
type Item = T;
[src]

Returns an iterator over each of the points in the Selection.

pub fn into_iter(self) -> IntoIter<T>

Important traits for IntoIter<T>

impl<T> Iterator for IntoIter<T> where
    T: Ord + Clone + Finite
type Item = T;
[src]

Returns an iterator over each of the points in the Selection.

Trait Implementations

impl<T: Clone> Clone for Selection<T>[src]

impl<T: Debug> Debug for Selection<T>[src]

impl<T> Default for Selection<T> where
    T: Ord + Clone,
    RawInterval<T>: Normalize
[src]

impl<T: Eq> Eq for Selection<T>[src]

impl<T> Extend<Interval<T>> for Selection<T> where
    T: Ord + Clone,
    RawInterval<T>: Normalize
[src]

impl<T> From<Interval<T>> for Selection<T> where
    T: Ord + Clone,
    RawInterval<T>: Normalize
[src]

impl<T> FromIterator<Interval<T>> for Selection<T> where
    T: Ord + Clone,
    RawInterval<T>: Normalize
[src]

impl<T> FromIterator<T> for Selection<T> where
    T: Ord + Clone,
    RawInterval<T>: Normalize
[src]

impl<T: Hash> Hash for Selection<T>[src]

impl<T> IntoIterator for Selection<T> where
    T: Ord + Clone + Finite
[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?

impl<T: PartialEq> PartialEq<Selection<T>> for Selection<T>[src]

impl<T> StructuralEq for Selection<T>[src]

impl<T> StructuralPartialEq for Selection<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Selection<T> where
    T: RefUnwindSafe

impl<T> Send for Selection<T> where
    T: Send

impl<T> Sync for Selection<T> where
    T: Sync

impl<T> Unpin for Selection<T> where
    T: Unpin

impl<T> UnwindSafe for Selection<T> where
    T: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.