#range #merge #overlap #tool

merged_range

rangeset that can merge overlap

1 unstable release

0.1.0 Apr 3, 2023

#10 in #overlap

Download history 297/week @ 2024-04-15 243/week @ 2024-04-22 163/week @ 2024-04-29 225/week @ 2024-05-06 228/week @ 2024-05-13 93/week @ 2024-05-20 153/week @ 2024-05-27 114/week @ 2024-06-03 173/week @ 2024-06-10 163/week @ 2024-06-17 126/week @ 2024-06-24 59/week @ 2024-07-01 188/week @ 2024-07-08 317/week @ 2024-07-15 158/week @ 2024-07-22 317/week @ 2024-07-29

986 downloads per month

Apache-2.0

25KB
555 lines

merged_range

A crate that can merge overlapping ranges

Apache licensed CI

Overview

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).

Example

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);

License

This project is licensed under the MIT license.

Dependencies

~31KB