Struct rangemap::set::RangeSet

source ·
pub struct RangeSet<T> { /* private fields */ }
Expand description

A set whose items are stored as (half-open) ranges bounded inclusively below and exclusively above (start..end).

See RangeMap’s documentation for more details.

Implementations§

source§

impl<T> RangeSet<T>
where T: Ord + Clone,

source

pub fn new() -> Self

Makes a new empty RangeSet.

source

pub fn get(&self, value: &T) -> Option<&Range<T>>

Returns a reference to the range covering the given key, if any.

source

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

Returns true if any range in the set covers the specified value.

source

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

Gets an ordered iterator over all ranges, ordered by range.

source

pub fn clear(&mut self)

Clears the set, removing all elements.

source

pub fn len(&self) -> usize

Returns the number of elements in the set.

source

pub fn is_empty(&self) -> bool

Returns true if the set contains no elements.

source

pub fn intersection<'a>(&'a self, other: &'a Self) -> Intersection<'a, T>

Return an iterator over the intersection of two range sets.

source

pub fn union<'a>(&'a self, other: &'a Self) -> Union<'a, T>

Return an iterator over the union of two range sets.

source

pub fn insert(&mut self, range: Range<T>)

Insert a range into the set.

If the inserted range either overlaps or is immediately adjacent any existing range, then the ranges will be coalesced into a single contiguous range.

§Panics

Panics if range start >= end.

source

pub fn remove(&mut self, range: Range<T>)

Removes a range from the set, if all or any of it was present.

If the range to be removed partially overlaps any ranges in the set, then those ranges will be contracted to no longer cover the removed range.

§Panics

Panics if range start >= end.

source

pub fn gaps<'a>(&'a self, outer_range: &'a Range<T>) -> Gaps<'a, T>

Gets an iterator over all the maximally-sized ranges contained in outer_range that are not covered by any range stored in the set.

If the start and end of the outer range are the same and it does not overlap any stored range, then a single empty gap will be returned.

The iterator element type is Range<T>.

source

pub fn overlapping<R: Borrow<Range<T>>>( &self, range: R ) -> Overlapping<'_, T, R>

Gets an iterator over all the stored ranges that are either partially or completely overlapped by the given range.

The iterator element type is &Range<T>.

source

pub fn overlaps(&self, range: &Range<T>) -> bool

Returns true if any range in the set completely or partially overlaps the given range.

source

pub fn first(&self) -> Option<&Range<T>>

Returns the first range in the set, if one exists. The range is the minimum range in this set.

source

pub fn last(&self) -> Option<&Range<T>>

Returns the last range in the set, if one exists. The range is the maximum range in this set.

Trait Implementations§

source§

impl<T: Ord + Clone> BitAnd for &RangeSet<T>

§

type Output = RangeSet<T>

The resulting type after applying the & operator.
source§

fn bitand(self, other: Self) -> Self::Output

Performs the & operation. Read more
source§

impl<T: Ord + Clone> BitOr for &RangeSet<T>

§

type Output = RangeSet<T>

The resulting type after applying the | operator.
source§

fn bitor(self, other: Self) -> Self::Output

Performs the | operation. Read more
source§

impl<T: Clone> Clone for RangeSet<T>

source§

fn clone(&self) -> RangeSet<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for RangeSet<T>
where T: Ord + Clone + Debug,

source§

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

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

impl<T> Default for RangeSet<T>

source§

fn default() -> Self

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

impl<T> Extend<Range<T>> for RangeSet<T>
where T: Ord + Clone,

source§

fn extend<I: IntoIterator<Item = Range<T>>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<T: Ord + Clone, const N: usize> From<[Range<T>; N]> for RangeSet<T>

source§

fn from(value: [Range<T>; N]) -> Self

Converts to this type from the input type.
source§

impl<T> FromIterator<Range<T>> for RangeSet<T>
where T: Ord + Clone,

source§

fn from_iter<I: IntoIterator<Item = Range<T>>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl<T: Hash> Hash for RangeSet<T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T> IntoIterator for RangeSet<T>

§

type Item = Range<T>

The type of the elements being iterated over.
§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T: Ord> Ord for RangeSet<T>

source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<T: PartialEq> PartialEq for RangeSet<T>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: PartialOrd> PartialOrd for RangeSet<T>

source§

fn partial_cmp(&self, other: &RangeSet<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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T: Eq> Eq for RangeSet<T>

source§

impl<T> StructuralPartialEq for RangeSet<T>

Auto Trait Implementations§

§

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

§

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

§

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

§

impl<T> Unpin for RangeSet<T>

§

impl<T> UnwindSafe for RangeSet<T>
where T: RefUnwindSafe,

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
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.