#union-find #range #disjoint-set #primitive-integer

no-std range_union_find

A union-find data structure for ranges

10 releases

0.5.0 Jun 2, 2023
0.4.4 Jan 3, 2023
0.4.3 Oct 23, 2022
0.4.2 May 19, 2022
0.4.1 Jul 2, 2021

#1186 in Data structures

Download history 9965/week @ 2024-06-09 13249/week @ 2024-06-16 15199/week @ 2024-06-23 12204/week @ 2024-06-30 7035/week @ 2024-07-07 6258/week @ 2024-07-14 7336/week @ 2024-07-21 6132/week @ 2024-07-28 5241/week @ 2024-08-04 5138/week @ 2024-08-11 6708/week @ 2024-08-18 5795/week @ 2024-08-25 7243/week @ 2024-09-01 5708/week @ 2024-09-08 3823/week @ 2024-09-15 6919/week @ 2024-09-22

23,721 downloads per month
Used in 2 crates (via choice-string)

MIT/Apache

65KB
1K SLoC

range_union_find

Crates.io Crates.io License License

This crate implements a union-find data structure for ranges that supports PrimInts and Floats.

See the API documentation for more information.


lib.rs:

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.

Dependencies

~140–430KB