org.feijoas.mango.common.collect.mutable

RangeMapLike

Related Doc: package mutable

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

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
Shrinkable[Range[K, O]], Growable[(Range[K, O], V)], Clearable, collect.RangeMapLike[K, V, O, Repr], HasNewBuilder[(Range[K, O], V), Repr], AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. RangeMapLike
  2. Shrinkable
  3. Growable
  4. Clearable
  5. RangeMapLike
  6. HasNewBuilder
  7. AnyRef
  8. 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 clear(): Unit

    Removes all associations from this range map.

    Removes all associations from this range map.

    Definition Classes
    RangeMapLike → Growable → Clearable
  3. 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
  4. 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
  5. abstract def newBuilder: Builder[(Range[K, O], V), Repr]

    Attributes
    protected[this]
    Definition Classes
    HasNewBuilder
  6. abstract def put(range: Range[K, O], value: V): Unit

    Maps a range to a specified value.

    Maps a range to a specified value.

    Specifically, after a call to put(range, value), if range.contains(k), then get(k) will return value.

    If range is empty, then this is a no-op.

  7. abstract def remove(range: Range[K, O]): Unit

    Removes all associations from this range map in the specified range.

    Removes all associations from this range map in the specified range.

    If !range.contains(k), get(k) will return the same result before and after a call to remove(range). If range.contains(k), then after a call to remove(range), get(k) will return None.

  8. 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
  9. abstract def subRangeMap(range: Range[K, O]): Repr

    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.

    The returned range map will throw an IllegalArgumentException on an attempt to insert a range not enclosed by range.

    Definition Classes
    RangeMapLikeRangeMapLike
    Annotations
    @throws( classOf[IllegalArgumentException] )

Concrete Value Members

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

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

    Definition Classes
    AnyRef → Any
  3. def ++=(xs: TraversableOnce[(Range[K, O], V)]): RangeMapLike.this.type

    Definition Classes
    Growable
  4. final def +=(kv: (Range[K, O], V)): RangeMapLike.this.type

    Alias for #put(range, value)

    Alias for #put(range, value)

    Definition Classes
    RangeMapLike → Growable
  5. def +=(elem1: (Range[K, O], V), elem2: (Range[K, O], V), elems: (Range[K, O], V)*): RangeMapLike.this.type

    Definition Classes
    Growable
  6. def --=(xs: TraversableOnce[Range[K, O]]): RangeMapLike.this.type

    Definition Classes
    Shrinkable
  7. final def -=(range: Range[K, O]): RangeMapLike.this.type

    Alias for #remove(range)

    Alias for #remove(range)

    Definition Classes
    RangeMapLike → Shrinkable
  8. def -=(elem1: Range[K, O], elem2: Range[K, O], elems: Range[K, O]*): RangeMapLike.this.type

    Definition Classes
    Shrinkable
  9. final def ==(arg0: Any): Boolean

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

    Definition Classes
    Any
  11. def clone(): AnyRef

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

    Definition Classes
    AnyRef
  13. 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
  14. def finalize(): Unit

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

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

    Returns asMapOfRanges().hashCode().

    Returns asMapOfRanges().hashCode().

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

    Returns true if this range map contains no ranges.

    Returns true if this range map contains no ranges.

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

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

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

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

    Definition Classes
    AnyRef
  22. def putAll(rangeMap: collect.RangeMap[K, V, O]): Unit

    Puts all the associations from rangeMap into this range map.

  23. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  24. 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
  25. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Shrinkable[Range[K, O]]

Inherited from Growable[(Range[K, O], V)]

Inherited from Clearable

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

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

Inherited from AnyRef

Inherited from Any

Ungrouped