charlesahunt / rangetreemap   0.3.1

MIT License GitHub

A data structure mapping ranges to values based on a TreeMap

Scala versions: 2.12

RangeTreeMap

A generic map from ranges to values based on a TreeMap backed by Scala's red-black tree.

CircleCI Maven Central Waffle.io - Columns and their card count codecov.io

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.

Installation

sbt

"com.charlesahunt" %% "range-tree-map" % "0.3.1"

mill

ivy"com.charlesahunt::range-tree-map:0.3.1"

Usage example

    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

Release History

  • 0.3.1
    • Fix bug in putCoalesce with intersections on different values
  • 0.3.0
    • Complete putCoalesce - First release with full functionality
  • 0.2.3
    • Fix put to create discreet ranges, refactor putCoalesce which still needs to be completed
  • 0.2.2
    • Fix bug with intersection which reverses the result lower and upper bound in the RangeKey
  • 0.2.1
    • Rough completion of putCoalescing along with intersection and disjoint
  • 0.1.5
    • Fix inclusive bugs in enclose and intersects functionality, add tests
  • 0.1.4
    • Initial design and structuring, some basic functionality

Meta

Charles Hunt – Website[email protected]

Distributed under the MIT license. See LICENSE for more information.

Contributing

  1. Fork it (https://github.com/charlesahunt/rangetreemap/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request