merged_range2

Crates.iomerged_range2
lib.rsmerged_range2
version1.0.0
created_at2025-01-15 09:28:24.899353+00
updated_at2025-01-15 09:28:24.899353+00
descriptionrangeset that can merge overlapping ranges (fork of merged_range)
homepagehttps://github.com/dlight/merged_range2
repositoryhttps://github.com/dlight/merged_range2
max_upload_size
id1517306
size42,740
Elias Gabriel Amaral da Silva (dlight)

documentation

README

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.

Commit count: 13

cargo fmt