Package org.apache.pekko.util
Class TypedMultiMap<T,K>
java.lang.Object
org.apache.pekko.util.TypedMultiMap<T,K>
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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription$plus$plus(TypedMultiMap<T, K> other) Add all entries from the other map, overwriting existing entries.static <T,K> TypedMultiMap<T, K> empty()Obtain the empty map for the given key type and key–value type function.booleanscala.collection.immutable.Set<K>Obtain all mappings for the given key.inthashCode()Return a map that has the given value added to the mappings for the given key.keyRemoved(T key) Return a map that has all mappings for the given key removed.scala.collection.immutable.Set<T>keySet()Return the set of keys which are mapped to non-empty value sets.Return a map that has the given mapping from the given key removed.toString()valueRemoved(Object value) Return a map that has the given value removed from all keys.
-
Constructor Details
-
TypedMultiMap
public TypedMultiMap()
-
-
Method Details
-
empty
Obtain the empty map for the given key type and key–value type function. -
keySet
Return the set of keys which are mapped to non-empty value sets. -
inserted
Return a map that has the given value added to the mappings for the given key. -
get
Obtain all mappings for the given key. -
valueRemoved
Return a map that has the given value removed from all keys. -
keyRemoved
Return a map that has all mappings for the given key removed. -
removed
Return a map that has the given mapping from the given key removed. -
setAll
-
$plus$plus
Add all entries from the other map, overwriting existing entries.FIXME: should it merge, instead?
-
toString
-
equals
-
hashCode
public int hashCode()
-