[−][src]Struct normalize_interval::selection::Selection
A possibly noncontiguous collection of Interval
s of the type T
.
Implementations
impl<T> Selection<T> where
T: Ord + Clone,
RawInterval<T>: Normalize,
[src]
T: Ord + Clone,
RawInterval<T>: Normalize,
pub fn new() -> Self
[src]
pub fn empty() -> Self
[src]
Constructs a new empty Selection
.
pub fn full() -> Self
[src]
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
Selection
s.
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
Selection
s.
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 Selection
s.
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]
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>;
Returns an iterator over each of the Interval
s 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]
Important traits for IntoIntervalIter<T>
impl<T> Iterator for IntoIntervalIter<T> where
T: Ord + Clone,
RawInterval<T>: Normalize, type Item = Interval<T>;
Returns an iterator over each of the Interval
s in the Selection
.
impl<T> Selection<T> where
T: Ord + Clone + Finite,
[src]
T: Ord + Clone + Finite,
pub fn iter(&self) -> Iter<T>ⓘ
[src]
Returns an iterator over each of the points in the Selection
.
pub fn into_iter(self) -> IntoIter<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]
T: Ord + Clone,
RawInterval<T>: Normalize,
impl<T: Eq> Eq for Selection<T>
[src]
impl<T> Extend<Interval<T>> for Selection<T> where
T: Ord + Clone,
RawInterval<T>: Normalize,
[src]
T: Ord + Clone,
RawInterval<T>: Normalize,
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = Interval<T>>,
[src]
I: IntoIterator<Item = Interval<T>>,
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl<T> From<Interval<T>> for Selection<T> where
T: Ord + Clone,
RawInterval<T>: Normalize,
[src]
T: Ord + Clone,
RawInterval<T>: Normalize,
impl<T> FromIterator<Interval<T>> for Selection<T> where
T: Ord + Clone,
RawInterval<T>: Normalize,
[src]
T: Ord + Clone,
RawInterval<T>: Normalize,
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = Interval<T>>,
[src]
I: IntoIterator<Item = Interval<T>>,
impl<T> FromIterator<T> for Selection<T> where
T: Ord + Clone,
RawInterval<T>: Normalize,
[src]
T: Ord + Clone,
RawInterval<T>: Normalize,
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = T>,
[src]
I: IntoIterator<Item = T>,
impl<T: Hash> Hash for Selection<T>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> IntoIterator for Selection<T> where
T: Ord + Clone + Finite,
[src]
T: Ord + Clone + Finite,
type Item = T
The type of the elements being iterated over.
type IntoIter = IntoIter<T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
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,
T: RefUnwindSafe,
impl<T> Send for Selection<T> where
T: Send,
T: Send,
impl<T> Sync for Selection<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Selection<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Selection<T> where
T: RefUnwindSafe + UnwindSafe,
T: RefUnwindSafe + UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,