#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 308/week @ 2024-07-28 223/week @ 2024-08-04 224/week @ 2024-08-11 203/week @ 2024-08-18 171/week @ 2024-08-25 116/week @ 2024-09-01 53/week @ 2024-09-08 74/week @ 2024-09-15 89/week @ 2024-09-22 26/week @ 2024-09-29 51/week @ 2024-10-06 47/week @ 2024-10-13 29/week @ 2024-10-20 37/week @ 2024-10-27 41/week @ 2024-11-03 17/week @ 2024-11-10

125 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