pub struct Interval<T>where
T: IntervalType,{
pub start: T,
pub end: T,
}
Expand description
Structure to represent an interval.
Fields§
§start: T
§end: T
Implementations§
Source§impl<T> Interval<T>where
T: IntervalType,
impl<T> Interval<T>where
T: IntervalType,
Sourcepub fn new(low: T, high: T) -> Self
pub fn new(low: T, high: T) -> Self
Constructs a new interval.
§Example
use space_partitioning::interval_tree::Interval;
let interval = Interval::new(-2.0, 10.0);
assert_eq!(interval.start, -2.0);
assert_eq!(interval.end, 10.0);
Sourcepub fn overlaps_with(&self, other: &Interval<T>) -> bool
pub fn overlaps_with(&self, other: &Interval<T>) -> bool
Checks whether the current interval overlaps with another one.
§Example
use space_partitioning::interval_tree::Interval;
let interval = Interval::from(-2.0..=10.0);
assert!(interval.overlaps_with(&(0.0..=2.0).into()));
assert!(!interval.overlaps_with(&(20.0..=30.0).into()));
Trait Implementations§
Source§impl<T> From<&RangeInclusive<T>> for Interval<T>where
T: IntervalType,
impl<T> From<&RangeInclusive<T>> for Interval<T>where
T: IntervalType,
Source§fn from(range: &RangeInclusive<T>) -> Self
fn from(range: &RangeInclusive<T>) -> Self
Constructs an interval from a `&RangeInclusive
§Example
use space_partitioning::interval_tree::Interval;
let range = -2.0..=10.0;
let interval: Interval<_> = (&range).into();
assert_eq!(interval.start, -2.0);
assert_eq!(interval.end, 10.0);
Source§impl<T> From<(T, T)> for Interval<T>where
T: IntervalType,
impl<T> From<(T, T)> for Interval<T>where
T: IntervalType,
Source§fn from(interval: (T, T)) -> Self
fn from(interval: (T, T)) -> Self
Constructs an interval from a tuple.
§Example
use space_partitioning::interval_tree::Interval;
let interval: Interval<_> = (-2.0, 10.0).into();
assert_eq!(interval.start, -2.0);
assert_eq!(interval.end, 10.0);
assert_eq!(interval, Interval::from((-2.0, 10.0)));
Source§impl<T> From<Interval<T>> for IntervalTree<T, ()>where
T: IntervalType,
impl<T> From<Interval<T>> for IntervalTree<T, ()>where
T: IntervalType,
Source§impl<T> From<RangeInclusive<T>> for Interval<T>where
T: IntervalType,
impl<T> From<RangeInclusive<T>> for Interval<T>where
T: IntervalType,
Source§fn from(range: RangeInclusive<T>) -> Self
fn from(range: RangeInclusive<T>) -> Self
Constructs an interval from a `RangeInclusive
§Example
use space_partitioning::interval_tree::Interval;
let interval: Interval<_> = (-2.0..=10.0).into();
assert_eq!(interval.start, -2.0);
assert_eq!(interval.end, 10.0);
assert_eq!(interval, Interval::from(-2.0..=10.0));
Source§impl<T> Ord for Interval<T>where
T: IntervalType + Ord,
impl<T> Ord for Interval<T>where
T: IntervalType + Ord,
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T> PartialOrd for Interval<T>where
T: IntervalType + PartialOrd,
impl<T> PartialOrd for Interval<T>where
T: IntervalType + PartialOrd,
impl<T> Copy for Interval<T>where
T: IntervalType + Copy,
impl<T> Eq for Interval<T>where
T: IntervalType + Eq,
impl<T> StructuralPartialEq for Interval<T>where
T: IntervalType,
Auto Trait Implementations§
impl<T> Freeze for Interval<T>where
T: Freeze,
impl<T> RefUnwindSafe for Interval<T>where
T: RefUnwindSafe,
impl<T> Send for Interval<T>where
T: Send,
impl<T> Sync for Interval<T>where
T: Sync,
impl<T> Unpin for Interval<T>where
T: Unpin,
impl<T> UnwindSafe for Interval<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more