Package pascal.taie.util.collection
Interface TwoKeyMultiMap<K1,K2,V>
- Type Parameters:
K1
- type of first keys in this mapK2
- type of second keys in this mapV
- type of values in this map
- All Known Implementing Classes:
AbstractTwoKeyMultiMap
,MapMultiMapTwoKeyMultiMap
public interface TwoKeyMultiMap<K1,K2,V>
A collection that maps two-key pairs to values, similar to
TwoKeyMap
,
but in which each two-key pair may be associated with multiple values.
The values associated with the same two-key pair contain no duplicates.
You can visualize the contents of a two-key multimap either as a map from keys
to multimaps as values:
- k1 -> { k2 -> [v1, v2], k3 -> [v3] }
- k2 -> { k4 -> [v1, v4] }
... or as a single "flattened" collection of key1-key2-value triples:
- k1, k2 -> v1
- k1, k2 -> v2
- k1, k3 -> v3
- k2, k4 -> v1
- k2, k4 -> v4
Note that both null
keys and values are not permitted in this map.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all the mappings from this map.boolean
boolean
containsKey
(K1 key1) boolean
containsKey
(K1 key1, K2 key2) boolean
containsValue
(V value) Set<TwoKeyMap.Entry<K1,
K2, V>> entrySet()
default void
forEach
(TriConsumer<K1, K2, V> action) Performs the given action for all key1-key2-value triples contained in this map.boolean
isEmpty()
boolean
Stores a key1-key2-value triple in this two-key multimap.boolean
Removes a single key1-key2-value triple from this two-key multimap, if it exists.boolean
Removes all values associated with the two-key pair.int
size()
-
Method Details
-
contains
- Returns:
true
if given key1-key2-value mapping is contained in this two-key multimap.
-
containsKey
- Returns:
true
if this two-key multimap contains the mapping withkey1
as the first key andkey2
as the second key.
-
containsKey
- Returns:
true
if this two-key multimap contains at least one mapping withkey1
as the first key.
-
containsValue
- Returns:
true
if this two-key multimap contains at least one mapping withvalue
as the value. Note that this operation may be slow compared tocontainsKey(Object)
.
-
get
- Returns:
- an unmodifiable view of the values associated with given keys in this multimap, if the two-key pair is absent; otherwise, returns an empty set.
-
get
- Returns:
- an unmodifiable view of the values associated with given key in this two-key multimap, if the key is absent; otherwise, returns an empty multimap.
-
put
Stores a key1-key2-value triple in this two-key multimap.- Returns:
true
if this two-key multimap changed.
-
remove
Removes a single key1-key2-value triple from this two-key multimap, if it exists.- Returns:
true
if the two-key multimap changed
-
removeAll
Removes all values associated with the two-key pair.- Returns:
true
if the multimap changed.
-
twoKeySet
- Returns:
- an unmodifiable view of all distinct two-key pairs
contained in this two-key multimap. Note that the result contains
a two-key pair if and only if this map maps that key pair to
at least one non-
null
value.
-
entrySet
Set<TwoKeyMap.Entry<K1,K2, entrySet()V>> - Returns:
- an unmodifiable view of all key1-key2-value triples
contained in this two-key multimap, as
TwoKeyMap.Entry
instances.
-
forEach
Performs the given action for all key1-key2-value triples contained in this map. -
clear
void clear()Removes all the mappings from this map. The map will be empty after this call returns. -
isEmpty
boolean isEmpty()- Returns:
true
if this map contains no key1-key2-value mappings.
-
size
int size()- Returns:
- the number of key1-key2-value mappings in this map.
-