interface VariantMultiMap<K,V>
A type-variant immutable MultiMap of key type K, and value type V. In the Map, each key has at least one value. See the MultiMap documentation and the VariantMultiMap API documentation
Companion namespace: VariantMultiMap
Extends: VariantMultiMapBase<K,V,Tp>
Implemented by: VariantMultiMap.NonEmpty<K,V>
Type parameters
Name | Description |
---|---|
K | the key type |
V | the value type |
Type-variance means that both the key and value types can be widened in a type-safe way without casting. @note As a consequence of being variant, the type does not contain methods that (can) add new elements to the collection.
Properties
isEmpty
Returns true if the collection is empty.
isEmpty
keyMap
Returns the Map representation of this collection.
keyMap
keySize
Returns the number of keys in the collection.
keySize
size
Returns the number of unique key-value combinations in this collection.
size
Methods
[Symbol.iterator]
Returns a FastIterator
instance used to iterate over the values of this Iterable
.
[Symbol.iterator]
FastIterator
instance used to iterate over the values of this Iterable
.assumeNonEmpty
Returns the collection as a .NonEmpty type
assumeNonEmpty
filter
Returns a collection containing only those entries that satisfy given pred
predicate.
filter
pred
predicate.forEach
Performs given function f
for each entry of the collection, using given state
as initial traversal state.
forEach
f
for each entry of the collection, using given state
as initial traversal state.getValues
Returns the value collection associated to the given key
.
getValues
key
.hasEntry
Returns true if the given key
has the given value
as one of its values in the collection.
hasEntry
key
has the given value
as one of its values in the collection.hasKey
Returns true if the given key
is present in the collection.
hasKey
key
is present in the collection.nonEmpty
Returns true if there is at least one entry in the collection, and instructs the compiler to treat the collection as a .NonEmpty type.
nonEmpty
removeEntries
Returns the collection where given entries
are removed.
removeEntries
entries
are removed.removeEntry
Returns the collection where given value
if removed from the values associated with given key
.
removeEntry
value
if removed from the values associated with given key
.removeKey
Returns the collection where the values associated with given key
are removed.
removeKey
key
are removed.removeKeyAndGet
Returns a tuple containing the collection of which the given key
is removed, and the values that are associated with that key. If the key is not present, it will return undefined instead.
removeKeyAndGet
key
is removed, and the values that are associated with that key. If the key is not present, it will return undefined instead.removeKeys
Returns the collection where the values associated with given keys
are removed.
removeKeys
keys
are removed.stream
Returns a Stream containing all entries of this collection as tuples of key and value.
stream
streamKeys
Returns a Stream containing all keys of this collection.
streamKeys
streamValues
Returns a Stream containing all values of this collection.
streamValues
toArray
Returns an array containing all entries in this collection.
toArray
toJSON
Returns a JSON representation of this collection.
toJSON
toString
Returns a string representation of this collection.
toString