merged_range2 1.0.0

rangeset that can merge overlapping ranges (fork of merged_range)
Documentation
  • Coverage
  • 100%
    11 out of 11 items documented1 out of 10 items with examples
  • Size
  • Source code size: 42.74 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 448.56 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • dlight/merged_range2
    0 0 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • dlight

Note: this crate is a fork of the original merged_range crate, which is not maintained anymore. More details in the issue #1.

merged_range2

A crate that can merge overlapping ranges.

Apache licensed crates.io docs.rs CI

Overview

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

Example

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

License

This project is licensed under the Apache license.