RangeSetRef

Struct RangeSetRef 

Source
pub struct RangeSetRef<T>(/* private fields */);
Expand description

A reference to a range set

Implementations§

Source§

impl<T> RangeSetRef<T>

Source

pub const fn empty() -> &'static Self

Create a new range set reference for an empty range set

Source

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.

Source

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)

Source

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.

Source

pub const fn boundaries(&self) -> &[T]

The boundaries of the range set, guaranteed to be strictly sorted

Source

pub fn contains(&self, value: &T) -> bool
where T: Ord,

true if the value is contained in the range set

Source

pub const fn is_empty(&self) -> bool

true if the range set is empty

Source

pub fn is_all(&self) -> bool
where T: RangeSetEntry,

true if the range set contains all values

Source

pub fn intersects(&self, that: &RangeSetRef<T>) -> bool
where 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.

Source

pub fn is_disjoint(&self, that: &RangeSetRef<T>) -> bool
where T: Ord,

true if this range set is disjoint from another range set

Source

pub fn is_subset(&self, that: &RangeSetRef<T>) -> bool
where 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

Source

pub fn is_superset(&self, that: &RangeSetRef<T>) -> bool
where 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

Source

pub fn iter(&self) -> Iter<'_, T>

iterate over all ranges in this range set

Source

pub fn intersection<A>(&self, that: &RangeSetRef<T>) -> RangeSet<A>
where A: Array<Item = T>, T: Ord + Clone,

intersection

Source

pub fn union<A>(&self, that: &RangeSetRef<T>) -> RangeSet<A>
where A: Array<Item = T>, T: Ord + Clone,

union

Source

pub fn difference<A>(&self, that: &RangeSetRef<T>) -> RangeSet<A>
where A: Array<Item = T>, T: Ord + Clone,

difference

Source

pub fn symmetric_difference<A>(&self, that: &RangeSetRef<T>) -> RangeSet<A>
where A: Array<Item = T>, T: Ord + Clone,

symmetric difference (xor)

Trait Implementations§

Source§

impl<T, A: Array<Item = T>> AsRef<RangeSetRef<T>> for RangeSet<A>

Source§

fn as_ref(&self) -> &RangeSetRef<T>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T, A: Array<Item = T>> Borrow<RangeSetRef<T>> for RangeSet<A>

Source§

fn borrow(&self) -> &RangeSetRef<T>

Immutably borrows from an owned value. Read more
Source§

impl<T: Debug> Debug for RangeSetRef<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for &RangeSetRef<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Ord> Ord for RangeSetRef<T>

Source§

fn cmp(&self, other: &RangeSetRef<T>) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl<T: PartialEq> PartialEq for RangeSetRef<T>

Source§

fn eq(&self, other: &RangeSetRef<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd> PartialOrd for RangeSetRef<T>

Source§

fn partial_cmp(&self, other: &RangeSetRef<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Eq> Eq for RangeSetRef<T>

Source§

impl<T> StructuralPartialEq for RangeSetRef<T>

Auto Trait Implementations§

§

impl<T> Freeze for RangeSetRef<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for RangeSetRef<T>
where T: RefUnwindSafe,

§

impl<T> Send for RangeSetRef<T>
where T: Send,

§

impl<T> !Sized for RangeSetRef<T>

§

impl<T> Sync for RangeSetRef<T>
where T: Sync,

§

impl<T> Unpin for RangeSetRef<T>
where T: Unpin,

§

impl<T> UnwindSafe for RangeSetRef<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more