A generic map from ranges to values based on a TreeMap backed by Scala's red-black tree.
The underlying data structure is a TreeMap backed by a Red-black tree mapping from a lower bound of K
to a
RangeEntry[K, V]
, sorted by an implicit Ordering[K]
. Overlapping ranges are allowed with put
, non overlapping
ranges are handled using putCoalesce
.
sbt
"com.charlesahunt" %% "range-tree-map" % "0.1.5"
mill
ivy"com.charlesahunt::range-tree-map:0.1.5"
import scala.math.Ordering._
val rangeMap = RangeTreeMap.apply[Int, String]
val rangeKey = RangeKey[Int](lower = 5, upper = 10)
rangeMap.put(rangeKey, "exampleValue")
For more examples and usage, please refer to the Wiki
- 0.1.5
- Fix inclusive bugs in enclose and intersects functionality, add tests
- 0.1.4
- Mostly functionally complete,
putCoalescing
still needs to be finished
- Mostly functionally complete,
Charles Hunt – Website – charlesalberthunt@gmail.com
Distributed under the MIT license. See LICENSE
for more information.
- Fork it (https://github.com/charlesahunt/rangetreemap/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request