A mapping from disjoint nonempty ranges to non-null values.
Implementation trait for immutable RangeMap
Implementation trait for immutable RangeMap
A mapping from disjoint nonempty ranges to non-null values. Queries look up the value associated with the range (if any) that contains a specified key.
In contrast to RangeSet, no "coalescing" is done of connected ranges, even if they are mapped to the same value.
Usage example:
import org.feijoas.mango.common.collect.mutable import org.feijoas.mango.common.collect.Range import math.Ordering.Int // mutable range map val rangeMap = mutable.RangeMap(Range.open(3, 7) -> "1") //Map((3..7) -> 1) rangeMap += Range.closed(9, 10) -> "2" // Map((3..7) -> 1, [9..10] -> 2) rangeMap += Range.closed(12, 16) -> "3" // Map((3..7) -> 1, [9..10] -> 2, [12..16] -> 3) val sub = rangeMap.subRangeMap(Range.closed(5, 11)) // Map([5..7) -> 1, [9..10] -> 2) sub.put(Range.closed(7, 9), "4") // sub = Map([5..7) -> 1, [7..9] -> 4, (9..10] -> 2) // rangeMap = Map((3..7) -> 1, [7..9] -> 4, (9..10] -> 2, [12..16] -> 3)
0.9
A range set is a set comprising zero or more nonempty, disconnected ranges of type C
for which an Ordering[C]
is defined.
A range set is a set comprising zero or more nonempty, disconnected ranges of type C
for which an Ordering[C]
is defined.
Note that the behavior of Range#isEmpty()
and Range#isConnected(Range)
may
not be as expected on discrete ranges. See the Scaladoc of those methods for details.
For a Set
whose contents are specified by a Range, see ContiguousSet.
Usage example:
import org.feijoas.mango.common.collect.Bound._ import org.feijoas.mango.common.collect._ import math.Ordering.Int // immutable range set: val rangeSet = RangeSet(Range.open(1, 3), Range.closed(4, 9)) // {(1,3), [4,9]} val subSet = rangeSet.subRangeSet(Range.closed(2, 6)) // union view {[2,3), [4,6]} // mutable range set: val mutableRangeSet = mutable.RangeSet(Range.closed(1, 10)) // {[1, 10]} mutableRangeSet += Range.closedOpen(11, 15) // disconnected range: {[1, 10], [11, 15)} mutableRangeSet += Range.closedOpen(15, 20) // connected range; {[1, 10], [11, 20)} mutableRangeSet += Range.openClosed(0, 0) // empty range; {[1, 10], [11, 20)} mutableRangeSet -= Range.open(5, 10) // splits [1, 10]; {[1, 5], [10, 10], [11, 20)}
0.8
Implementation trait for immutable RangeSet
Implementation trait for immutable RangeSet
A range set is a set comprising zero or more nonempty, disconnected ranges of type C
for which an Ordering[C]
is defined.
Note that the behavior of Range#isEmpty()
and Range#isConnected(Range)
may
not be as expected on discrete ranges. See the Scaladoc of those methods for details.
For a Set
whose contents are specified by a Range, see ContiguousSet.
Usage example:
import org.feijoas.mango.common.collect.Bound._ import org.feijoas.mango.common.collect._ import math.Ordering.Int // immutable range set: val rangeSet = RangeSet(Range.open(1, 3), Range.closed(4, 9)) // {(1,3), [4,9]} val subSet = rangeSet.subRangeSet(Range.closed(2, 6)) // union view {[2,3), [4,6]} // mutable range set: val mutableRangeSet = mutable.RangeSet(Range.closed(1, 10)) // {[1, 10]} mutableRangeSet += Range.closedOpen(11, 15) // disconnected range: {[1, 10], [11, 15)} mutableRangeSet += Range.closedOpen(15, 20) // connected range; {[1, 10], [11, 20)} mutableRangeSet += Range.openClosed(0, 0) // empty range; {[1, 10], [11, 20)} mutableRangeSet -= Range.open(5, 10) // splits [1, 10]; {[1, 5], [10, 10], [11, 20)}
0.8
Factory for immutable RangeMap
Factory for immutable RangeSet
A mapping from disjoint nonempty ranges to non-null values. Queries look up the value associated with the range (if any) that contains a specified key.
In contrast to RangeSet, no "coalescing" is done of connected ranges, even if they are mapped to the same value.
Usage example:
0.9