public class ConcurrentHashMap extends AbstractMap implements ConcurrentMap, SizedMap, Cloneable, Serializable
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ConcurrentHashMap.Entry |
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
ConcurrentHashMap()
Constructs an empty ConcurrentHashMap with the default initial
capacity(16) and the default load factor(0.75).
|
ConcurrentHashMap(int initialCapacity)
Constructs an empty ConcurrentHashMap with the specified initial
capacity and the default load factor(0.75).
|
ConcurrentHashMap(int initialCapacity,
float loadFactor)
Constructs an empty ConcurrentHashMap with the specified initial
capacity and load factor.
|
ConcurrentHashMap(Map m)
Constructs a new ConcurrentHashMap with the same mappings as the
specified Map.
|
| Modifier and Type | Method and Description |
|---|---|
int |
capacity()
Returns the current capacity of backing table in this map.
|
void |
clear()
Removes all mappings from this map.
|
Object |
clone()
Returns a shallow copy of this ConcurrentHashMap instance: the
keys and values themselves are not cloned.
|
boolean |
containsKey(Object key)
Returns true if this map contains a mapping for the
specified key.
|
boolean |
containsValue(Object value)
Returns true if this map maps one or more keys to the
specified value.
|
protected ConcurrentHashMap.Entry |
createEntry(int h,
Object k,
Object v,
ConcurrentHashMap.Entry n) |
Set |
entrySet()
Returns a collection view of the mappings contained in this map.
|
Object |
get(Object key)
Returns the value to which the specified key is mapped in this identity
hash map, or null if the map contains no mapping for this key.
|
protected ConcurrentHashMap.Entry |
getEntry(Object key)
Returns the entry associated with the specified key in the
ConcurrentHashMap.
|
int |
getMaxSize()
The maximum number of entries, or Integer.MAX_VALUE for no limit.
|
boolean |
isEmpty()
Returns true if this map contains no key-value mappings.
|
boolean |
isFull()
Whether the map is full.
|
Set |
keySet()
Returns a set view of the keys contained in this map.
|
float |
loadFactor()
Returns the load factor for this map.
|
void |
overflowRemoved(Object key,
Object value)
Overridable callback for when an overflow entry is automatically removed.
|
Object |
put(Object key,
Object value)
Associates the specified value with the specified key in this map.
|
void |
putAll(Map t)
Copies all of the mappings from the specified map to this map
These mappings will replace any mappings that
this map had for any of the keys currently in the specified map.
|
Object |
putIfAbsent(Object key,
Object value) |
Iterator |
randomEntryIterator()
Iterate over map entries, beginning at an arbitrary
(not strictly random) entry.
|
Object |
remove(Object key)
Removes the mapping for this key from this map if present.
|
Map.Entry |
removeRandom()
Remove an arbitrary(not strictly random) entry from the map.
|
void |
setMaxSize(int maxSize)
The maximum number of entries, or Integer.MAX_VALUE for no limit.
|
int |
size()
Returns the number of key-value mappings in this map.
|
Collection |
values()
Returns a collection view of the values contained in this map.
|
equals, hashCode, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, remove, replace, replace, replaceAllpublic ConcurrentHashMap(int initialCapacity,
float loadFactor)
initialCapacity - The initial capacity.loadFactor - The load factor.IllegalArgumentException - if the initial capacity is negative
or the load factor is nonpositive.public ConcurrentHashMap(int initialCapacity)
initialCapacity - the initial capacity.IllegalArgumentException - if the initial capacity is negative.public ConcurrentHashMap()
public ConcurrentHashMap(Map m)
m - the map whose mappings are to be placed in this map.NullPointerException - if the specified map is null.public final int capacity()
public final float loadFactor()
public int getMaxSize()
SizedMapgetMaxSize in interface SizedMappublic void setMaxSize(int maxSize)
SizedMapsetMaxSize in interface SizedMappublic boolean isFull()
SizedMappublic void overflowRemoved(Object key, Object value)
SizedMapoverflowRemoved in interface SizedMappublic final int size()
size in interface Mapsize in class AbstractMappublic final boolean isEmpty()
isEmpty in interface MapisEmpty in class AbstractMappublic Object get(Object key)
get in interface Mapget in class AbstractMapkey - the key whose associated value is to be returned.put(Object, Object)public final boolean containsKey(Object key)
containsKey in interface MapcontainsKey in class AbstractMapkey - The key whose presence in this map is to be testedprotected ConcurrentHashMap.Entry getEntry(Object key)
public Object put(Object key, Object value)
put in interface Mapput in class AbstractMapkey - key with which the specified value is to be associated.value - value to be associated with the specified key.public Object putIfAbsent(Object key, Object value)
putIfAbsent in interface Mappublic final void putAll(Map t)
putAll in interface MapputAll in class AbstractMapt - mappings to be stored in this map.NullPointerException - if the specified map is null.public Object remove(Object key)
remove in interface Mapremove in class AbstractMapkey - key whose mapping is to be removed from the map.public void clear()
clear in interface Mapclear in class AbstractMappublic Map.Entry removeRandom()
ConcurrentMapremoveRandom in interface ConcurrentMappublic Iterator randomEntryIterator()
ConcurrentMaprandomEntryIterator in interface ConcurrentMappublic final boolean containsValue(Object value)
containsValue in interface MapcontainsValue in class AbstractMapvalue - value whose presence in this map is to be tested.public final Object clone()
clone in class AbstractMapprotected ConcurrentHashMap.Entry createEntry(int h, Object k, Object v, ConcurrentHashMap.Entry n)
public final Set keySet()
keySet in interface MapkeySet in class AbstractMappublic final Collection values()
values in interface Mapvalues in class AbstractMappublic final Set entrySet()
entrySet in interface MapentrySet in class AbstractMapMap.EntryCopyright © 2006–2022 Apache Software Foundation. All rights reserved.