Crates.io | merged_range |
lib.rs | merged_range |
version | 0.1.0 |
source | src |
created_at | 2023-04-03 01:38:09.17734 |
updated_at | 2023-04-03 01:38:09.17734 |
description | rangeset that can merge overlap |
homepage | |
repository | https://github.com/datenlord/merged_range |
max_upload_size | |
id | 828736 |
size | 37,904 |
A crate that can merge overlapping ranges
merged_range 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. and it can merge the new range with the existing ranges. insert and query time complexity is both O(logn).
add dependency to Cargo.toml
[dependencies]
merged_range = "0.1.0"
then use it in your code
use merged_range::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 MIT license.