Interface ListMultiMap<K,V>
public interface ListMultiMap<K,V>
ListMultiMap
for example
ListMultiMap<Integer, String> map = ListMultiMap.of();
map.put(1, "a");
map.put(1, "a");
map.put(1, "b");
List<String> list2 = map.get(2); // is null
List<String> list2 = map.of(2); // is empty list
list2.add("2 - a");
list2.add("2 - a");
map.sizeValue(); // sizeValue == 5
map.containsValue("a"); // true
map.containsValue("b"); // true
Set<Integer> keySet = this.map.keySet();
- Author:
- 渔民小镇
- date:
- 2023-12-07
-
Method Summary
Modifier and TypeMethodDescriptionasMap()default voidclear()default Collection<V> Clear all elements within the collection corresponding to the key.default booleancontainsKey(K key) default booleancontainsValue(V value) static <K,V> ListMultiMap <K, V> create()Create a ListMultiMap (framework internal implementation).entrySet()default booleanisEmpty()keySet()static <K,V> ListMultiMap <K, V> of()Create a ListMultiMap (framework internal implementation)ofIfAbsent(K key, Consumer<List<V>> consumer) Get an element collection by key, creating the collection if it does not exist.default booleanAdd an element to the collection associated with the specified key.default intsize()The number of key-collection mappings in the mapdefault intThe total number of all values across all collections in the map.
-
Method Details
-
asMap
-
ofIfAbsent
Get an element collection by key, creating the collection if it does not exist.The returned element collection is guaranteed to be non-null; a new one will be created if absent. The first time the collection for a key is created, the consumer will be called with the newly created collection. Developers can use the consumer for any necessary initialization.
- Parameters:
key- keyconsumer- consumer- Returns:
- the collection
-
of
-
get
-
entrySet
-
create
Create a ListMultiMap (framework internal implementation). Please useof()instead.- Type Parameters:
K- kV- v- Returns:
- ListMultiMap
-
of
Create a ListMultiMap (framework internal implementation)- Type Parameters:
K- kV- v- Returns:
- ListMultiMap
-
clearAll
Clear all elements within the collection corresponding to the key.- Parameters:
key- key- Returns:
- the collection after clearing, guaranteed to be non-null
-
size
default int size()The number of key-collection mappings in the map- Returns:
- size
-
sizeValue
default int sizeValue()The total number of all values across all collections in the map.- Returns:
- value size
-
put
-
isEmpty
default boolean isEmpty() -
containsKey
-
containsValue
-
clear
default void clear() -
keySet
-