Note: this crate is a fork of the original merged_range crate, which is not maintained anymore. More details in the issue #1.
A crate that can merge overlapping ranges.
merged_range2 is used to query whether the given range is contained in the existing range. If it is contained, return true, otherwise return false. It uses a sorted vector to store ranges, it can merge the new range with the existing ranges.
Insert and query time complexity is both O(logn).
Add the dependency to Cargo.toml
[dependencies]
merged_range2 = "1.0.0"Then use it in your code
use merged_range2::MergedRange;
let mut mr = MergedRange::new();
mr.insert_range(&(1..10));
mr.insert_range(&(5..20));
assert_eq!(mr.contains_range(&(3..15)), true);
assert_eq!(mr.contains_range(&(10..21)), false);This project is licensed under the Apache license.