K - keyV - valuepublic class NonAbsentHashMap<K,V> extends HashMap<K,V>
Map> map = new HashMap>();
List list = map.get(key);
if(list==null){
list = new ArrayList();
map.put(key, list);
}
list.add(e);
using this class, your code will be:
Supplier> supplier = new Supplier>(){
public List get(K key){
return new ArrayList();
}
};
Map> map = new NonAbsentHashMap>();
map.get(key).add(e);
Map,
HashMap,
WrappedNonAbsentMap,
序列化表格AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| 构造器和说明 |
|---|
NonAbsentHashMap(int initialCapacity,
float loadFactor,
Supplier<K,V> supplier) |
NonAbsentHashMap(int initialCapacity,
Supplier<K,V> supplier) |
NonAbsentHashMap(Map<? extends K,? extends V> m,
Supplier<K,V> supplier) |
NonAbsentHashMap(Supplier<K,V> supplier) |
| 限定符和类型 | 方法和说明 |
|---|---|
V |
get(Object key) |
V |
get(Object key,
Supplier<K,V> supplier) |
V |
getIfPresent(Object key) |
V |
putIfAbsent(K key,
V value) |
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, getOrDefault, isEmpty, keySet, merge, put, putAll, remove, remove, replace, replace, replaceAll, size, valuesequals, hashCode, toStringCopyright © 2022. All rights reserved.