org.feijoas.mango.common.collect

mutable

package mutable

Visibility
  1. Public
  2. All

Type Members

  1. trait RangeMap[K, V, O <: Ordering[K]] extends collect.RangeMap[K, V, O] with RangeMapLike[K, V, O, RangeMap[K, V, O]]

    A mapping from disjoint nonempty ranges to non-null values.

    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)
    Annotations
    @Beta()
    Since

    0.9

  2. trait RangeMapLike[K, V, O <: Ordering[K], +Repr <: RangeMapLike[K, V, O, Repr] with RangeMap[K, V, O]] extends collect.RangeMapLike[K, V, O, Repr] with Growable[(Range[K, O], V)] with Shrinkable[Range[K, O]]

    Implementation trait for mutable RangeMap

    Implementation trait for mutable 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)
    Annotations
    @Beta()
    Since

    0.9

  3. trait RangeSet[C, O <: Ordering[C]] extends collect.RangeSet[C, O] with RangeSetLike[C, O, RangeSet[C, O]]

    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)}
    Annotations
    @Beta()
    Since

    0.8

  4. trait RangeSetLike[C, O <: Ordering[C], +Repr <: RangeSetLike[C, O, Repr] with RangeSet[C, O]] extends collect.RangeSetLike[C, O, Repr] with Growable[Range[C, O]] with Shrinkable[Range[C, O]]

    Implementation trait for mutable RangeSet

    Implementation trait for mutable 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)}
    Annotations
    @Beta()
    Since

    0.8

Value Members

  1. object RangeMap extends RangeMapFactory[RangeMap]

    Factory for immutable RangeMap

  2. object RangeSet extends RangeSetFactory[RangeSet]

    Factory for mutable RangeSet

Ungrouped