pub struct Range<T> {
pub start: T,
pub end: T,
}
Expand description
A 1D range. Internally represented as start and end. (as opposed to a start and length) If range A contains value x and range B contains value x, then A intersects B. There is no protection against “degenerate” Ranges where start>end.
A point is consindered inside of a range if the point is in [start,end]
.
Fields§
§start: T
§end: T
Implementations§
source§impl<T: Copy + Ord + Sub<Output = T> + Signed> Range<T>
impl<T: Copy + Ord + Sub<Output = T> + Signed> Range<T>
pub fn distance_to_point(&self, pos: T) -> Option<T>
sourcepub fn difference_to_point(&self, pos: T) -> Option<T>
pub fn difference_to_point(&self, pos: T) -> Option<T>
Positive if point is to the right of the range. Negative if point is to the left of range.
source§impl<T: Copy + PartialOrd> Range<T>
impl<T: Copy + PartialOrd> Range<T>
sourcepub fn contains_ext(&self, pos: T) -> Ordering
pub fn contains_ext(&self, pos: T) -> Ordering
Like contains() but returns Ord. If the pos is strictly less than the range.start, return less. If the pos is greater of equal to the range.end, return greater. else, return equal.
sourcepub fn contains(&self, pos: T) -> bool
pub fn contains(&self, pos: T) -> bool
Returns true if the point is inside of the range or on top of.
sourcepub fn subdivide(&self, divider: T) -> (Range<T>, Range<T>)
pub fn subdivide(&self, divider: T) -> (Range<T>, Range<T>)
Subdivides the range. No floating point calculations are done.
pub fn is_valid(&self) -> bool
pub fn grow_to_fit(&mut self, b: &Range<T>)
sourcepub fn contains_range(&self, val: &Range<T>) -> bool
pub fn contains_range(&self, val: &Range<T>) -> bool
Returns true if self contains the specified range.
sourcepub fn intersects(&self, val: &Range<T>) -> bool
pub fn intersects(&self, val: &Range<T>) -> bool
Returns true if two ranges intersect.