[−][src]Struct normalize_interval::interval::Interval
A contiguous interval of the type T.
Interval
s are Normalize
d when created. For Finite
types, open
bounds will be converted to the nearest contained closed bound.
Implementations
impl<T> Interval<T> where
T: Ord + Clone,
RawInterval<T>: Normalize,
[src]
T: Ord + Clone,
RawInterval<T>: Normalize,
pub fn new(left: Bound<T>, right: Bound<T>) -> Self
[src]
Constructs a new Interval
from the given Bound
s.
Examples
let interval: Interval<i32> = Interval::new(Include(3), Exclude(7));
Finite
types will have their bounds closed:
let interval: Interval<i32> = Interval::new(Exclude(-3), Exclude(7)); assert_eq!(interval, Interval::new(Include(-2), Include(6)));
If the bounds are out of order, and empty Interval
will be returned.
let interval: Interval<i32> = Interval::new(Exclude(7), Exclude(-7)); assert_eq!(interval, Interval::empty());
pub fn empty() -> Self
[src]
pub fn point(point: T) -> Self
[src]
Constructs a new degenerate Interval
containing the given point.
Example
let interval: Interval<i32> = Interval::point(3);
pub fn open(left: T, right: T) -> Self
[src]
Constructs a new bounded open Interval
from the given points.
Examples
let interval: Interval<i32> = Interval::open(3, 7);
Finite
types will have their bounds closed:
let interval: Interval<i32> = Interval::open(-3, 7); assert_eq!(interval, Interval::new(Include(-2), Include(6)));
If the bounds are out of order, and empty Interval
will be returned.
let interval: Interval<i32> = Interval::open(7, -7); assert_eq!(interval, Interval::empty());
pub fn left_open(left: T, right: T) -> Self
[src]
Constructs a new bounded left-open Interval
from the given points.
Examples
let interval: Interval<i32> = Interval::left_open(3, 7);
Finite
types will have their bounds closed:
let interval: Interval<i32> = Interval::left_open(-3, 7); assert_eq!(interval, Interval::new(Include(-2), Include(7)));
If the bounds are out of order, and empty Interval
will be returned.
let interval: Interval<i32> = Interval::left_open(7, -7); assert_eq!(interval, Interval::empty());
If the bounds are identical, a point Interval
will be returned.
let interval: Interval<i32> = Interval::left_open(5, 5); assert_eq!(interval, Interval::point(5));
pub fn right_open(left: T, right: T) -> Self
[src]
Constructs a new bounded right-open Interval
from the given points.
Examples
let interval: Interval<i32> = Interval::right_open(3, 7);
Finite
types will have their bounds closed:
let interval: Interval<i32> = Interval::right_open(-3, 7); assert_eq!(interval, Interval::new(Include(-3), Include(6)));
If the bounds are out of order, and empty Interval
will be returned.
let interval: Interval<i32> = Interval::right_open(7, -7); assert_eq!(interval, Interval::empty());
If the bounds are identical, a point Interval
will be returned.
let interval: Interval<i32> = Interval::right_open(5, 5); assert_eq!(interval, Interval::point(5));
pub fn closed(left: T, right: T) -> Self
[src]
Constructs a new bounded closed Interval
from the given points.
Examples
let interval: Interval<i32> = Interval::closed(3, 7);
If the bounds are out of order, and empty Interval
will be returned.
let interval: Interval<i32> = Interval::closed(7, -7); assert_eq!(interval, Interval::empty());
If the bounds are identical, a point Interval
will be returned.
let interval: Interval<i32> = Interval::closed(5, 5); assert_eq!(interval, Interval::point(5));
pub fn left_closed(left: T, right: T) -> Self
[src]
Constructs a new bounded left-closed Interval
from the given points.
Examples
let interval: Interval<i32> = Interval::left_closed(3, 7);
Finite
types will have their bounds closed:
let interval: Interval<i32> = Interval::left_closed(-3, 7); assert_eq!(interval, Interval::new(Include(-3), Include(6)));
If the bounds are out of order, and empty Interval
will be returned.
let interval: Interval<i32> = Interval::left_closed(7, -7); assert_eq!(interval, Interval::empty());
If the bounds are identical, a point Interval
will be returned.
let interval: Interval<i32> = Interval::left_closed(5, 5); assert_eq!(interval, Interval::point(5));
pub fn right_closed(left: T, right: T) -> Self
[src]
Constructs a new bounded right-closed Interval
from the given points.
Examples
let interval: Interval<i32> = Interval::right_closed(3, 7);
Finite
types will have their bounds closed:
let interval: Interval<i32> = Interval::right_closed(-3, 7); assert_eq!(interval, Interval::new(Include(-2), Include(7)));
If the bounds are out of order, and empty Interval
will be returned.
let interval: Interval<i32> = Interval::right_closed(7, -7); assert_eq!(interval, Interval::empty());
If the bounds are identical, a point Interval
will be returned.
let interval: Interval<i32> = Interval::right_closed(5, 5); assert_eq!(interval, Interval::point(5));
pub fn unbounded_from(point: T) -> Self
[src]
Constructs a new right-unbounded Interval
from (and including) the
given point.
Examples
let interval: Interval<i32> = Interval::unbounded_from(3);
Finite
types will have their bounds closed:
let interval: Interval<i32> = Interval::unbounded_from(7); assert_eq!(interval, Interval::new(Include(7), Include(i32::MAX)));
pub fn unbounded_to(point: T) -> Self
[src]
Constructs a new left-unbounded Interval
to (and including) the
given point.
Examples
let interval: Interval<i32> = Interval::unbounded_to(3);
Finite
types will have their bounds closed:
let interval: Interval<i32> = Interval::unbounded_to(7); assert_eq!(interval, Interval::new(Include(i32::MIN), Include(7)));
pub fn unbounded_up_from(point: T) -> Self
[src]
Constructs a new right-unbounded Interval
from (but excluding) the
given point.
Examples
let interval: Interval<i32> = Interval::unbounded_up_from(3);
Finite
types will have their bounds closed:
let interval: Interval<i32> = Interval::unbounded_up_from(7); assert_eq!(interval, Interval::new(Include(8), Include(i32::MAX)));
pub fn unbounded_up_to(point: T) -> Self
[src]
Constructs a new left-unbounded Interval
to (but excluding) the
given point.
Examples
let interval: Interval<i32> = Interval::unbounded_up_to(3);
Finite
types will have their bounds closed:
let interval: Interval<i32> = Interval::unbounded_up_to(7); assert_eq!(interval, Interval::new(Include(i32::MIN), Include(6)));
pub fn full() -> Self
[src]
Constructs a new unbounded Interval
containing all points.
Examples
let interval: Interval<i32> = Interval::full();
Finite
types will have their bounds closed:
let interval: Interval<i32> = Interval::full(); assert_eq!(interval, Interval::new(Include(i32::MIN), Include(i32::MAX)));
pub fn into_non_empty(self) -> Option<Self>
[src]
Converts the Interval
into an Option
, returning None
if it is
empty.
let interval: Interval<i32> = Interval::closed(0, 4); assert_eq!(interval.into_non_empty(), Some(Interval::closed(0, 4))); let interval: Interval<i32> = Interval::empty(); assert_eq!(interval.into_non_empty(), None);
pub fn lower_bound(&self) -> Option<Bound<T>>
[src]
Returns the lower Bound
of the Interval
, or None
if the
Interval
is empty
.
Examples
let interval: Interval<i32> = Interval::closed(-3, 5); assert_eq!(interval.lower_bound(), Some(Include(-3)));
Finite
types will have their bounds closed:
let interval: Interval<i32> = Interval::open(-3, 5); assert_eq!(interval.lower_bound(), Some(Include(-2)));
pub fn upper_bound(&self) -> Option<Bound<T>>
[src]
Returns the upper Bound
of the Interval
, or None
if the
Interval
is empty
.
Examples
let interval: Interval<i32> = Interval::closed(-3, 5); assert_eq!(interval.upper_bound(), Some(Include(5)));
Finite
types will have their bounds closed:
let interval: Interval<i32> = Interval::open(-3, 5); assert_eq!(interval.upper_bound(), Some(Include(4)));
pub fn infimum(&self) -> Option<T>
[src]
Returns the greatest lower bound of the Interval
, or None
if the
Interval
is empty
or unbounded below.
Examples
let interval: Interval<i32> = Interval::closed(-3, 5); assert_eq!(interval.infimum(), Some(-3));
Finite
types will have their bounds closed:
let interval: Interval<i32> = Interval::open(-3, 5); assert_eq!(interval.infimum(), Some(-2));
pub fn supremum(&self) -> Option<T>
[src]
Returns the least upper bound of the Interval
, or None
if the
Interval
is empty
or unbounded above.
Examples
let interval: Interval<i32> = Interval::closed(-3, 5); assert_eq!(interval.supremum(), Some(5));
Finite
types will have their bounds closed:
let interval: Interval<i32> = Interval::open(-3, 5); assert_eq!(interval.supremum(), Some(4));
pub fn size(&self) -> Option<T> where
T: Sub<Output = T>,
[src]
T: Sub<Output = T>,
Returns the size of the Interval
, or None
if it is either infinite
or empty.
Example
let interval: Interval<i32> = Interval::closed(-3, 7); assert_eq!(interval.size(), Some(10));
pub fn is_empty(&self) -> bool
[src]
Returns true
if the interval contains no points.
Example
let interval: Interval<i32> = Interval::closed(-3, 5); assert_eq!(interval.is_empty(), false); let interval: Interval<i32> = Interval::empty(); assert_eq!(interval.is_empty(), true);
pub fn is_degenerate(&self) -> bool
[src]
Returns true
if the interval contains a single point.
Example
let interval: Interval<i32> = Interval::closed(-3, 5); assert_eq!(interval.is_degenerate(), false); let interval: Interval<i32> = Interval::point(4); assert_eq!(interval.is_degenerate(), true);
pub fn is_proper(&self) -> bool
[src]
Returns true
if the interval contains more than one point.
Example
let interval: Interval<i32> = Interval::closed(-3, 5); assert_eq!(interval.is_proper(), true); let interval: Interval<i32> = Interval::point(4); assert_eq!(interval.is_proper(), false); let interval: Interval<i32> = Interval::empty(); assert_eq!(interval.is_proper(), false);
pub fn is_open(&self) -> bool
[src]
Returns true
if the interval is open.
Examples
let interval: Interval<i32> = Interval::left_open(-3, 5); assert_eq!(interval.is_open(), false); let interval: Interval<i32> = Interval::point(4); assert_eq!(interval.is_open(), false);
Note that the empty and full intervals are open:
let interval: Interval<i32> = Interval::empty(); assert_eq!(interval.is_open(), true); let interval: Interval<i32> = Interval::full(); assert_eq!(interval.is_open(), false);
pub fn is_left_open(&self) -> bool
[src]
Returns true
if the interval is left-open.
Examples
let interval: Interval<i32> = Interval::left_open(-3, 5); assert_eq!(interval.is_left_open(), false); let interval: Interval<i32> = Interval::closed(2, 4); assert_eq!(interval.is_left_open(), false);
Note that the left-unbounded intervals are considered left-open:
let interval: Interval<i32> = Interval::unbounded_to(4); assert_eq!(interval.is_left_open(), false); let interval: Interval<i32> = Interval::full(); assert_eq!(interval.is_left_open(), false);
pub fn is_right_open(&self) -> bool
[src]
Returns true
if the interval is right-open.
Examples
let interval: Interval<i32> = Interval::right_open(-3, 5); assert_eq!(interval.is_right_open(), false); let interval: Interval<i32> = Interval::closed(2, 4); assert_eq!(interval.is_right_open(), false);
Note that the right-unbounded intervals are considered right-open:
let interval: Interval<i32> = Interval::unbounded_from(4); assert_eq!(interval.is_right_open(), false); let interval: Interval<i32> = Interval::full(); assert_eq!(interval.is_right_open(), false);
pub fn is_half_open(&self) -> bool
[src]
Returns true
if the interval is half-open.
Examples
let interval: Interval<i32> = Interval::left_open(-3, 5); assert_eq!(interval.is_half_open(), false); let interval: Interval<i32> = Interval::closed(2, 4); assert_eq!(interval.is_half_open(), false);
Note that the half-unbounded intervals are considered half-open:
let interval: Interval<i32> = Interval::unbounded_to(4); assert_eq!(interval.is_half_open(), false); let interval: Interval<i32> = Interval::full(); assert_eq!(interval.is_half_open(), false);
pub fn is_closed(&self) -> bool
[src]
Returns true
if the interval is closed.
Examples
let interval: Interval<i32> = Interval::closed(-3, 5); assert_eq!(interval.is_closed(), true); let interval: Interval<i32> = Interval::left_open(-2, 4); assert_eq!(interval.is_closed(), true);
Note that the empty and full intervals are closed:
let interval: Interval<i32> = Interval::empty(); assert_eq!(interval.is_closed(), true); let interval: Interval<i32> = Interval::full(); assert_eq!(interval.is_closed(), true);
pub fn is_left_closed(&self) -> bool
[src]
Returns true
if the interval is left-closed.
Example
let interval: Interval<i32> = Interval::closed(-3, 5); assert_eq!(interval.is_left_closed(), true); let interval: Interval<i32> = Interval::left_open(-2, 4); assert_eq!(interval.is_left_closed(), true);
pub fn is_right_closed(&self) -> bool
[src]
Returns true
if the interval is right-closed.
Example
let interval: Interval<i32> = Interval::closed(-3, 5); assert_eq!(interval.is_right_closed(), true); let interval: Interval<i32> = Interval::right_open(-2, 4); assert_eq!(interval.is_right_closed(), true);
pub fn is_half_closed(&self) -> bool
[src]
Returns true
if the interval is half-closed.
Example
let interval: Interval<i32> = Interval::unbounded_to(-3); assert_eq!(interval.is_half_closed(), false); let interval: Interval<i32> = Interval::open(-2, 4); assert_eq!(interval.is_half_closed(), false);
pub fn is_bounded(&self) -> bool
[src]
Returns true
if the the interval is bounded.
Example
let interval: Interval<i32> = Interval::open(-2, 4); assert_eq!(interval.is_left_bounded(), true); let interval: Interval<i32> = Interval::unbounded_to(-3); assert_eq!(interval.is_left_bounded(), true);
pub fn is_left_bounded(&self) -> bool
[src]
Returns true
if the the interval is left-bounded.
Example
let interval: Interval<i32> = Interval::open(-2, 4); assert_eq!(interval.is_left_bounded(), true); let interval: Interval<i32> = Interval::unbounded_to(-3); assert_eq!(interval.is_left_bounded(), true);
pub fn is_right_bounded(&self) -> bool
[src]
Returns true
if the the interval is right-bounded.
Example
let interval: Interval<i32> = Interval::open(-2, 4); assert_eq!(interval.is_right_bounded(), true); let interval: Interval<i32> = Interval::unbounded_from(-3); assert_eq!(interval.is_right_bounded(), true);
pub fn is_half_bounded(&self) -> bool
[src]
Returns true
if the the interval is helf-bounded.
Example
let interval: Interval<i32> = Interval::unbounded_to(-2); assert_eq!(interval.is_half_bounded(), false); let interval: Interval<i32> = Interval::full(); assert_eq!(interval.is_half_bounded(), false);
pub fn contains(&self, point: &T) -> bool
[src]
Returns true
if the the interval contains the given point.
Example
let interval: Interval<i32> = Interval::closed(0, 20); assert_eq!(interval.contains(&2), true); assert_eq!(interval.contains(&-15), false);
pub fn intersects(&self, other: &Self) -> bool
[src]
Returns true
if the Interval
overlaps the given Interval
.
Example
let a: Interval<i32> = Interval::closed(-3, 5); let b: Interval<i32> = Interval::closed(4, 15); assert_eq!(a.intersects(&b), true); let a: Interval<i32> = Interval::closed(-3, 5); let b: Interval<i32> = Interval::closed(8, 12); assert_eq!(a.intersects(&b), false);
pub fn adjacent(&self, other: &Self) -> bool
[src]
Returns true
if the Interval
shares a bound with the given
Interval
.
Example
let a: Interval<i32> = Interval::closed(-3, 5); let b: Interval<i32> = Interval::closed(5, 15); assert_eq!(a.adjacent(&b), true); let a: Interval<i32> = Interval::closed(-3, 5); let b: Interval<i32> = Interval::closed(8, 12); assert_eq!(a.adjacent(&b), false);
pub fn complement(&self) -> impl Iterator<Item = Self>
[src]
Returns Interval
s containing all points not contained in the
Interval
.
Example
let interval: Interval<i32> = Interval::open(-3, 5); assert_eq!(interval.complement().collect::<Vec<_>>(), [Interval::unbounded_to(-3), Interval::unbounded_from(5)]);
pub fn intersect(&self, other: &Self) -> Self
[src]
Returns the largest Interval
whose points are all contained entirely
within the Interval
and the given Interval
.
Example
let a: Interval<i32> = Interval::closed(-3, 7); let b: Interval<i32> = Interval::closed(4, 13); assert_eq!(a.intersect(&b), Interval::closed(4, 7));
pub fn union(&self, other: &Self) -> impl Iterator<Item = Self>
[src]
Returns the Interval
s containing all points in the Interval
and the
given Interval
.
Example
let a: Interval<i32> = Interval::closed(-3, 7); let b: Interval<i32> = Interval::closed(4, 13); assert_eq!(a.union(&b).collect::<Vec<_>>(), [Interval::closed(-3, 13)]);
pub fn minus(&self, other: &Self) -> impl Iterator<Item = Self>
[src]
Returns the Interval
s containing all points in the Interval
which
are not in the given Interval
.
Example
let a: Interval<i32> = Interval::closed(-3, 7); let b: Interval<i32> = Interval::closed(4, 13); assert_eq!(a.minus(&b).collect::<Vec<_>>(), [Interval::right_open(-3, 4)]);
pub fn enclose(&self, other: &Self) -> Self
[src]
Returns the smallest Interval
that contains all of the points
contained within the Interval
and the given Interval
.
Example
let a: Interval<i32> = Interval::closed(-3, 5); let b: Interval<i32> = Interval::closed(9, 13); assert_eq!(a.enclose(&b), Interval::closed(-3, 13));
pub fn closure(&self) -> Self
[src]
Returns the smallest closed Interval
containing all of the points in
this Interval
.
Example
let interval: Interval<i32> = Interval::open(-3, 7); assert_eq!(interval.closure(), Interval::closed(-2, 6));
impl<T> Interval<T> where
T: Ord + Clone + Finite,
[src]
T: Ord + Clone + Finite,
pub fn iter(&self) -> Iter<T>ⓘ
[src]
Returns an Iterator
over the points in the Interval
. Only defined
for Finite
Interval
s.
Examples
let interval: Interval<i32> = Interval::open(3, 7); assert_eq!(interval.iter().collect::<Vec<_>>(), [4, 5, 6]);
The Interval
can be iterated in both directions.
let interval: Interval<i32> = Interval::open(3, 7); assert_eq!(interval.iter().rev().collect::<Vec<_>>(), [6, 5, 4]);
Trait Implementations
impl<T: Clone> Clone for Interval<T>
[src]
impl<T: Copy> Copy for Interval<T>
[src]
impl<T: Debug> Debug for Interval<T>
[src]
impl<T> Default for Interval<T> where
T: Ord + Clone,
RawInterval<T>: Normalize,
[src]
T: Ord + Clone,
RawInterval<T>: Normalize,
impl<T: Eq> Eq for Interval<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> From<Range<T>> for Interval<T> where
T: Ord + Clone,
RawInterval<T>: Normalize,
[src]
T: Ord + Clone,
RawInterval<T>: Normalize,
impl<T> From<RangeFrom<T>> for Interval<T> where
T: Ord + Clone,
RawInterval<T>: Normalize,
[src]
T: Ord + Clone,
RawInterval<T>: Normalize,
impl<T> From<RangeFull> for Interval<T> where
T: Ord + Clone,
RawInterval<T>: Normalize,
[src]
T: Ord + Clone,
RawInterval<T>: Normalize,
impl<T> From<RangeTo<T>> for Interval<T> where
T: Ord + Clone,
RawInterval<T>: Normalize,
[src]
T: Ord + Clone,
RawInterval<T>: Normalize,
impl<T> From<RangeToInclusive<T>> for Interval<T> where
T: Ord + Clone,
RawInterval<T>: Normalize,
[src]
T: Ord + Clone,
RawInterval<T>: Normalize,
fn from(r: RangeToInclusive<T>) -> Self
[src]
impl<T> From<T> for Interval<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: Hash> Hash for Interval<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 Interval<T> where
T: Ord + Clone + Finite,
[src]
T: Ord + Clone + Finite,
type Item = T
The type of the elements being iterated over.
type IntoIter = Iter<T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<T: PartialEq> PartialEq<Interval<T>> for Interval<T>
[src]
impl<T> StructuralEq for Interval<T>
[src]
impl<T> StructuralPartialEq for Interval<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Interval<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Interval<T> where
T: Send,
T: Send,
impl<T> Sync for Interval<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Interval<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Interval<T> where
T: UnwindSafe,
T: 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>,