merged_range 0.1.0

rangeset that can merge overlap
Documentation
  • Coverage
  • 100%
    7 out of 7 items documented1 out of 6 items with examples
  • Size
  • Source code size: 37.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 401.51 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • datenlord/merged_range
    3 5 2
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • themanforfree

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.