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.

Clears all the ranges stored in this 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.

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.

Functions like Self::has_range given input start..=end.

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.

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.

The resulting type after applying the & operator.

Computes the union of the two IntRangeUnionFind objects.

The resulting type after applying the | operator.

The resulting type after applying the ^ operator.

Performs the ^ operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. 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.

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

🔬 This is a nightly-only experimental API. (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.

Feeds this value into the given Hasher. Read more

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

The resulting type after applying the ! operator.

Performs the unary ! operation. Read more

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.

The resulting type after applying the - operator.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.