Crate range_union_find

Crate range_union_find 

Source
Expand description

Provides a data structure backed by a vector for unioning ranges of integers. We intelligently merge inserted ranges to minimize required storage.

Example usage:

let mut range_holder = RangeUnionFind::<u32>::new();
range_holder.insert_range(&(4..=8))?;
range_holder.insert_range(&(6..=10))?;
assert_eq!(range_holder.has_range(&(2..=12))?, OverlapType::Partial(7));
assert_eq!(range_holder.has_range(&(5..=9))?, OverlapType::Contained);

The main type is the RangeUnionFind struct, with the NumInRange trait implemented for primitive integer and float types that can be used to form ranges. While we make a best effort to support floating point ranges, unexpected issues may arise with floating point imprecision.

Structs§

FloatIsNan
Error returned when the float is NaN.
NonNanFloat
Wrapper for non-NaN floats that implements Eq and Ord.
RangeUnionFind
Struct representing a union of ranges. See the documentation for NonNanFloat’s impl of the Steppable trait for caveats when using this type with floating-point numbers.

Enums§

ContainedType
Enum describing what location an element has in a range.
OverlapType
Enum describing how a range may overlap with another range.
RangeOperationError
Enum describing how a range may be invalid.

Traits§

NumInRange
Trait representing number types over which intervals can be constructed.
Steppable
Trait representing number types which can be incrementally stepped.