K
- 键类型V
- 值类型public class MapWrapper<K,V> extends Object implements Map<K,V>, Iterable<Map.Entry<K,V>>, Serializable, Cloneable
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_INITIAL_CAPACITY
默认初始大小
|
protected static float |
DEFAULT_LOAD_FACTOR
默认增长因子
|
Constructor and Description |
---|
MapWrapper(Map<K,V> raw)
构造
|
MapWrapper(Supplier<Map<K,V>> mapFactory)
构造
通过传入一个Map从而确定Map的类型,子类需创建一个空的Map,而非传入一个已有Map,否则值可能会被修改 |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
MapWrapper<K,V> |
clone() |
V |
compute(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction) |
V |
computeIfAbsent(K key,
Function<? super K,? extends V> mappingFunction) |
V |
computeIfPresent(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction) |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<K,V>> |
entrySet() |
boolean |
equals(Object o) |
void |
forEach(BiConsumer<? super K,? super V> action) |
V |
get(Object key) |
V |
getOrDefault(Object key,
V defaultValue) |
Map<K,V> |
getRaw()
获取原始的Map
|
int |
hashCode() |
boolean |
isEmpty() |
Iterator<Map.Entry<K,V>> |
iterator() |
Set<K> |
keySet() |
V |
merge(K key,
V value,
BiFunction<? super V,? super V,? extends V> remappingFunction) |
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> m) |
V |
putIfAbsent(K key,
V value) |
V |
remove(Object key) |
boolean |
remove(Object key,
Object value) |
V |
replace(K key,
V value) |
boolean |
replace(K key,
V oldValue,
V newValue) |
void |
replaceAll(BiFunction<? super K,? super V,? extends V> function) |
int |
size() |
String |
toString() |
Collection<V> |
values() |
finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
protected static final float DEFAULT_LOAD_FACTOR
protected static final int DEFAULT_INITIAL_CAPACITY
public MapWrapper(Supplier<Map<K,V>> mapFactory)
mapFactory
- 空Map创建工厂public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
public boolean containsValue(Object value)
containsValue
in interface Map<K,V>
public boolean equals(Object o)
public int hashCode()
public void forEach(BiConsumer<? super K,? super V> action)
public void replaceAll(BiFunction<? super K,? super V,? extends V> function)
replaceAll
in interface Map<K,V>
public V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
computeIfAbsent
in interface Map<K,V>
public V getOrDefault(Object key, V defaultValue)
getOrDefault
in interface Map<K,V>
public V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
computeIfPresent
in interface Map<K,V>
public MapWrapper<K,V> clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
Copyright © 2024. All rights reserved.