Packages

class TypedMultiMap[T <: AnyRef, K[_ <: T]] extends AnyRef

An immutable multi-map that expresses the value type as a type function of the key type. Create it with a type constructor that expresses the relationship:

trait Key { type Type = T }
case class MyValue[T](...)

// type function from Key to MyValue
type KV[K <: Key] = MyValue[K#Type]

val map = TypedMultiMap.empty[Key, KV]

// a plain Int => String map would use this function:
type plain[K <: Int] = String

// a map T => T would use this function:
type identity[T <: AnyRef] = T

Caveat: using keys which take type parameters does not work due to conflicts with the existential interpretation of Key[_]. A workaround is to define a key type like above and provide a subtype that provides its type parameter as type member Type.

Source
TypedMultiMap.scala
Linear Supertypes
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TypedMultiMap
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. def ++(other: TypedMultiMap[T, K]): TypedMultiMap[T, K]

    Add all entries from the other map, overwriting existing entries.

    Add all entries from the other map, overwriting existing entries.

    FIXME: should it merge, instead?

  2. def equals(other: Any): Boolean
    Definition Classes
    TypedMultiMap → AnyRef → Any
  3. def get(key: T): Set[K[key.type]]

    Obtain all mappings for the given key.

  4. def hashCode(): Int
    Definition Classes
    TypedMultiMap → AnyRef → Any
  5. def inserted(key: T)(value: K[key.type]): TypedMultiMap[T, K]

    Return a map that has the given value added to the mappings for the given key.

  6. def keyRemoved(key: T): TypedMultiMap[T, K]

    Return a map that has all mappings for the given key removed.

  7. def keySet: Set[T]

    Return the set of keys which are mapped to non-empty value sets.

  8. def removed(key: T)(value: K[key.type]): TypedMultiMap[T, K]

    Return a map that has the given mapping from the given key removed.

  9. def setAll(key: T)(values: Set[K[key.type]]): TypedMultiMap[T, K]
  10. def toString(): String
    Definition Classes
    TypedMultiMap → AnyRef → Any
  11. def valueRemoved(value: Any): TypedMultiMap[T, K]

    Return a map that has the given value removed from all keys.