Struct range_union_find::IntRangeUnionFind [−][src]
pub struct IntRangeUnionFind<T> where
T: PrimInt, { /* fields omitted */ }
Expand description
Struct representing a union of integer ranges.
Implementations
Constructs a new IntRangeUnionFind
object.
Returns a tuple describing the range the element is in, as well as its location.
The range_id is a count of which range the element is in.
The enum indicates where the element is in the range, with
(Exterior,i)
meaning the exterior region before the i’th range.
See ContainedType
for an explanation of the enum values.
If the element is in a single-element range of the form a..=a
,
the enum will not be Exterior
, but its exact value is otherwise unspecified.
Example
let mut range_obj = IntRangeUnionFind::new(); range_obj.insert_range(&(10..20)); assert_eq!(range_obj.has_element_enum(&0), (ContainedType::Exterior, 0)); assert_eq!(range_obj.has_element_enum(&10), (ContainedType::Start, 0)); assert_eq!(range_obj.has_element_enum(&15), (ContainedType::Interior, 0)); assert_eq!(range_obj.has_element_enum(&19), (ContainedType::End, 0)); assert_eq!(range_obj.has_element_enum(&25), (ContainedType::Exterior, 1));
let mut range_obj = IntRangeUnionFind::new(); range_obj.insert_range(&(8..=8)); let (contain_enum, contain_id) = range_obj.has_element_enum(&8); assert_ne!(contain_enum, ContainedType::Exterior); assert_eq!(contain_id, 0);
Returns whether the element is contained in the stored ranges.
Returns false
when Self::has_element_enum
returns a
ContainedType::Exterior
enum, and true
otherwise.
pub fn has_range<U: RangeBounds<T>>(
&self,
range: &U
) -> Result<OverlapType<T>, RangeOperationError>
[src]
pub fn has_range<U: RangeBounds<T>>(
&self,
range: &U
) -> Result<OverlapType<T>, RangeOperationError>
[src]Returns how the given range overlaps with the stored ranges.
See OverlapType
for a description of the enum values.
Example
let mut range_obj = IntRangeUnionFind::new(); range_obj.insert_range(&(10..20)); range_obj.insert_range(&(-20..-10)); assert_eq!(range_obj.has_range(&(15..17))?, OverlapType::Contained); assert_eq!(range_obj.has_range(&(-5..5))?, OverlapType::Disjoint); assert_eq!(range_obj.has_range(&(0..20))?, OverlapType::Partial(10)); assert_eq!(range_obj.has_range(&(-15..15))?, OverlapType::Partial(10));
Errors
Returns RangeOperationError
if given range is invalid.
pub fn has_range_pair(
&self,
start: &T,
end: &T
) -> Result<OverlapType<T>, RangeOperationError>
[src]
pub fn has_range_pair(
&self,
start: &T,
end: &T
) -> Result<OverlapType<T>, RangeOperationError>
[src]Functions like Self::has_range
given input start..=end
.
pub fn insert_range<U: RangeBounds<T>>(
&mut self,
range: &U
) -> Result<(), RangeOperationError>
[src]
pub fn insert_range<U: RangeBounds<T>>(
&mut self,
range: &U
) -> Result<(), RangeOperationError>
[src]Inserts the range into the set of ranges.
Errors
Returns RangeOperationError
if the given range is invalid.
Functions like Self::insert_range
given input start..=end
.
pub fn remove_range<U: RangeBounds<T>>(
&mut self,
range: &U
) -> Result<(), RangeOperationError>
[src]
pub fn remove_range<U: RangeBounds<T>>(
&mut self,
range: &U
) -> Result<(), RangeOperationError>
[src]Removes the range from the set of ranges.
Errors
Returns RangeOperationError
if the given range is invalid.
Functions like Self::remove_range
given input start..=end
.
Creates a collection of RangeInclusive
with element type T
from a IntRangeUnionFind
object.
Converts a IntRangeUnionFind
object into a collection of RangeInclusive
with element type T
.
Trait Implementations
Computes the union of the two IntRangeUnionFind
objects.
type Output = IntRangeUnionFind<T>
type Output = IntRangeUnionFind<T>
The resulting type after applying the &
operator.
Computes the union of the two IntRangeUnionFind
objects.
type Output = IntRangeUnionFind<T>
type Output = IntRangeUnionFind<T>
The resulting type after applying the |
operator.
type Output = IntRangeUnionFind<T>
type Output = IntRangeUnionFind<T>
The resulting type after applying the ^
operator.
Performs the ^
operation. Read more
Returns the “default value” for a type. Read more
Calls Self::insert_range
for each range in the iterator.
Panics
Panics if any of the range insertions return an Err
.
extend_one
)Extends a collection with exactly one element.
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Calls Self::insert_range
for each range in the iterator.
Panics
Panics if any of the range insertions return an Err
.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Subtracts the rhs IntRangeUnionFind
object from the lhs one.
type Output = IntRangeUnionFind<T>
type Output = IntRangeUnionFind<T>
The resulting type after applying the -
operator.
Auto Trait Implementations
impl<T> RefUnwindSafe for IntRangeUnionFind<T> where
T: RefUnwindSafe,
impl<T> Send for IntRangeUnionFind<T> where
T: Send,
impl<T> Sync for IntRangeUnionFind<T> where
T: Sync,
impl<T> Unpin for IntRangeUnionFind<T> where
T: Unpin,
impl<T> UnwindSafe for IntRangeUnionFind<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more