Introducing RangeBoundsMap, a BTreeMap-like data-structure library where the keys are RangeBounds!
It's meant to be an intuitive and fairly-performant data-structure for storing range-like things.
I tried as much as possible to stick to standard rust naming conventions and standard library types such as std::ops::RangeBounds.
I was partly inspired by rangemap, in fact one of the main ambitions of the project was to be a more generic superset of rangemap.
I also spent a long time writing the documentation and code examples for every method and item in the crate, probably more time than actually writing code, so enjoy ☺️.
Here is a small example using RangeBoundsMap:
let mut map = RangeBoundsMap::new();
// 0 1 2 3 4 5 6 7 8 9 10
// ⬤---------○ ⬤-----○
map.insert_platonic(0..5, true);
map.insert_coalesce_overlapping(7..10, false);
assert_eq!(map.get_at_point(&2), Some(&true));
assert_eq!(map.get_at_point(&9), Some(&false));
assert_eq!(map.overlaps(&(-2..12)), true);
assert_eq!(map.contains_point(&20), false);
assert_eq!(map.contains_point(&5), true);
Links:
repo docs.rs lib.rs crates.io
Please consider becoming a stargazer of the repo, I only have one at the moment, myself 😢.