pub struct RangeSetRef<T>(/* private fields */);Expand description
A reference to a range set
Implementations§
Source§impl<T> RangeSetRef<T>
impl<T> RangeSetRef<T>
Sourcepub const fn single(value: &T) -> &Self
pub const fn single(value: &T) -> &Self
Create a new range set reference for a single boundary change
This produces a RangeSetRef that goes from off before value to on at
and after value.
Sourcepub fn new(boundaries: &[T]) -> Option<&Self>where
T: Ord,
pub fn new(boundaries: &[T]) -> Option<&Self>where
T: Ord,
Create a new range set reference
This performs a check that the boundaries are strictly sorted.
If you want to avoid this check, use new_unchecked
(behind a feature flag because it is unsafe)
Sourcepub fn split(&self, at: T) -> (&Self, &Self)where
T: Ord,
pub fn split(&self, at: T) -> (&Self, &Self)where
T: Ord,
Split this range set into two parts left, right at position at,
so that left is identical to self for all x < at
and right is identical to self for all x >= at.
More precisely: contains(left, x) == contains(ranges, x) for x < at contains(right, x) == contains(ranges, x) for x >= at
This is not the same as limiting the ranges to the left or right of
at, but it is much faster. It requires just a binary search and no
allocations.
Sourcepub const fn boundaries(&self) -> &[T]
pub const fn boundaries(&self) -> &[T]
The boundaries of the range set, guaranteed to be strictly sorted
Sourcepub fn contains(&self, value: &T) -> boolwhere
T: Ord,
pub fn contains(&self, value: &T) -> boolwhere
T: Ord,
true if the value is contained in the range set
Sourcepub fn is_all(&self) -> boolwhere
T: RangeSetEntry,
pub fn is_all(&self) -> boolwhere
T: RangeSetEntry,
true if the range set contains all values
Sourcepub fn intersects(&self, that: &RangeSetRef<T>) -> boolwhere
T: Ord,
pub fn intersects(&self, that: &RangeSetRef<T>) -> boolwhere
T: Ord,
true if this range set intersects from another range set
This is just the opposite of is_disjoint, but is provided for
better discoverability.
Sourcepub fn is_disjoint(&self, that: &RangeSetRef<T>) -> boolwhere
T: Ord,
pub fn is_disjoint(&self, that: &RangeSetRef<T>) -> boolwhere
T: Ord,
true if this range set is disjoint from another range set
Sourcepub fn is_subset(&self, that: &RangeSetRef<T>) -> boolwhere
T: Ord,
pub fn is_subset(&self, that: &RangeSetRef<T>) -> boolwhere
T: Ord,
true if this range set is a superset of another range set
A range set is considered to be a superset of itself
Sourcepub fn is_superset(&self, that: &RangeSetRef<T>) -> boolwhere
T: Ord,
pub fn is_superset(&self, that: &RangeSetRef<T>) -> boolwhere
T: Ord,
true if this range set is a subset of another range set
A range set is considered to be a subset of itself
Sourcepub fn intersection<A>(&self, that: &RangeSetRef<T>) -> RangeSet<A>
pub fn intersection<A>(&self, that: &RangeSetRef<T>) -> RangeSet<A>
intersection
Sourcepub fn union<A>(&self, that: &RangeSetRef<T>) -> RangeSet<A>
pub fn union<A>(&self, that: &RangeSetRef<T>) -> RangeSet<A>
union
Sourcepub fn difference<A>(&self, that: &RangeSetRef<T>) -> RangeSet<A>
pub fn difference<A>(&self, that: &RangeSetRef<T>) -> RangeSet<A>
difference
Sourcepub fn symmetric_difference<A>(&self, that: &RangeSetRef<T>) -> RangeSet<A>
pub fn symmetric_difference<A>(&self, that: &RangeSetRef<T>) -> RangeSet<A>
symmetric difference (xor)