pub struct KeyRange<Idx>where
Idx: Bounded,{
pub start: Idx,
pub end: Idx,
}
Expand description
A (half-open) range bounded inclusively below and exclusively above i.e.
[start..end)
.
If start >= end
, the range is considered wrapping and is equivalent to
covering union of two ranges: [start..MAX_VALUE]
and [0..end)
.
Fields§
§start: Idx
§end: Idx
Implementations§
source§impl<Idx> KeyRange<Idx>
impl<Idx> KeyRange<Idx>
sourcepub fn is_wrapping(&self) -> bool
pub fn is_wrapping(&self) -> bool
Returns true
if the range is wrapping, which is equivalent to union of
the following two ranges: [start..MAX_VALUE]
and [0..end)
..
sourcepub fn is_inverted(&self) -> bool
pub fn is_inverted(&self) -> bool
Returns true
if the range is inverted, i.e. start >= end
.
sourcepub fn ends_at_origin(&self) -> bool
pub fn ends_at_origin(&self) -> bool
Returns true
if the range ends at the origin.
This is useful for distinguishing a special case of non-wrapping range
that has inverted positions, end < start
, but is still
non-wrapping.
sourcepub fn covers_whole_ring(&self) -> bool
pub fn covers_whole_ring(&self) -> bool
Returns true
if the range covers the whole ring.
sourcepub fn is_overlapping(&self, other: &Self) -> bool
pub fn is_overlapping(&self, other: &Self) -> bool
Returns true
if the range overlaps with other
.
sourcepub fn is_continuous(&self, other: &Self) -> bool
pub fn is_continuous(&self, other: &Self) -> bool
Returns true
if one range is a continuation of the other.
That’s intervals do not intersect, but can be merged i.e. for a given intervals [a, b) and [b, c) the union is [a, c).