org.feijoas.mango.common.collect.immutable

RangeMap

Related Docs: object RangeMap | package immutable

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. 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

Linear Supertypes
RangeMapLike[K, V, O, RangeMap[K, V, O]], collect.RangeMap[K, V, O], collect.RangeMapLike[K, V, O, RangeMap[K, V, O]], HasNewBuilder[(Range[K, O], V), RangeMap[K, V, O]], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. RangeMap
  2. RangeMapLike
  3. RangeMap
  4. RangeMapLike
  5. HasNewBuilder
  6. AnyRef
  7. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def asMapOfRanges(): Map[Range[K, O], V]

    Returns this RangeMap as a map of ranges.

    Returns this RangeMap as a map of ranges.

    Warning: This differs from Guava which returns an unmodifiable view of this RangeMap which modifications to its range map are guaranteed to read through to the returned map.

    It is guaranteed that no empty ranges will be in the returned Map.

    Definition Classes
    RangeMapLike
  2. abstract def get(key: K): Option[V]

    Returns the value associated with the specified key in a Some, or None if there is no such value.

    Returns the value associated with the specified key in a Some, or None if there is no such value.

    Specifically, if any range in this range map contains the specified key, the value associated with that range is returned.

    Definition Classes
    RangeMapLike
  3. abstract def getEntry(key: K): Option[(Range[K, O], V)]

    Returns the range containing this key and its associated value in a Some, if such a range is present in the range map, or None otherwise.

    Returns the range containing this key and its associated value in a Some, if such a range is present in the range map, or None otherwise.

    Definition Classes
    RangeMapLike
  4. abstract def newBuilder: Builder[(Range[K, O], V), RangeMap[K, V, O]]

    Attributes
    protected[this]
    Definition Classes
    HasNewBuilder
  5. abstract def span(): Option[Range[K, O]]

    Returns the minimal range enclosing the ranges in this RangeMap in a Some or None if this range map is empty

    Returns the minimal range enclosing the ranges in this RangeMap in a Some or None if this range map is empty

    Definition Classes
    RangeMapLike
  6. abstract def subRangeMap(range: Range[K, O]): RangeMap[K, V, O]

    Returns a view of the part of this range map that intersects with range.

    Returns a view of the part of this range map that intersects with range.

    For example, if rangeMap had the entries [1, 5] => "foo", (6, 8) => "bar", (10, ‥) => "baz" then rangeMap.subRangeMap(Range.open(3, 12)) would return a range map with the entries (3, 5) => "foo", (6, 8) => "bar", (10, 12) => "baz".

    The returned range map supports all optional operations that this range map supports.

    Definition Classes
    RangeMapLike

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. def equals(obj: Any): Boolean

    Returns true if obj is another RangeMap that has an equivalent #asMapOfRanges().

    Returns true if obj is another RangeMap that has an equivalent #asMapOfRanges().

    Definition Classes
    RangeMapLike → AnyRef → Any
  8. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Returns asMapOfRanges().hashCode().

    Returns asMapOfRanges().hashCode().

    Definition Classes
    RangeMapLike → AnyRef → Any
  11. def isEmpty: Boolean

    Returns true if this range map contains no ranges.

    Returns true if this range map contains no ranges.

    Definition Classes
    RangeMapLike
  12. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  14. final def notify(): Unit

    Definition Classes
    AnyRef
  15. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  16. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  17. def toString(): String

    Returns a readable string representation of this range map.

    Returns a readable string representation of this range map.

    Definition Classes
    RangeMapLike → AnyRef → Any
  18. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from RangeMapLike[K, V, O, RangeMap[K, V, O]]

Inherited from collect.RangeMap[K, V, O]

Inherited from collect.RangeMapLike[K, V, O, RangeMap[K, V, O]]

Inherited from HasNewBuilder[(Range[K, O], V), RangeMap[K, V, O]]

Inherited from AnyRef

Inherited from Any

Ungrouped