K
- the type of keys maintained by this mapV
- the type of mapped valuespublic class ConcurrentIdentityHashMap<K,V> extends AbstractMap<K,V> implements ConcurrentMap<K,V>
ConcurrentMap
which is similar to
ConcurrentHashMap
.AbstractMap.SimpleImmutableEntry<K,V>
构造器和说明 |
---|
ConcurrentIdentityHashMap()
Creates a new, empty map with a default initial capacity (16), reference types (weak keys, strong values),
default load factor (0.75) and concurrencyLevel (16).
|
ConcurrentIdentityHashMap(int initialCapacity)
Creates a new, empty map with the specified initial capacity, and with default reference types (weak keys, strong
values), load factor (0.75) and concurrencyLevel (16).
|
ConcurrentIdentityHashMap(int initialCapacity,
float loadFactor)
Creates a new, empty map with the specified initial capacity and load factor and with the default reference types
(weak keys, strong values), and concurrencyLevel (16).
|
ConcurrentIdentityHashMap(int initialCapacity,
float loadFactor,
int concurrencyLevel)
Creates a new, empty map with the specified initial capacity, load factor and concurrency level.
|
ConcurrentIdentityHashMap(Map<? extends K,? extends V> m)
Creates a new map with the same mappings as the given map.
|
限定符和类型 | 方法和说明 |
---|---|
void |
clear()
Removes all of the mappings from this map.
|
boolean |
contains(Object value) |
boolean |
containsKey(Object key)
Tests if the specified object is a key in this table.
|
boolean |
containsValue(Object value)
Returns true if this map maps one or more keys to the specified value.
|
Enumeration<V> |
elements()
Returns an enumeration of the values in this table.
|
Set<Map.Entry<K,V>> |
entrySet() |
V |
get(Object key)
Returns the value to which the specified key is mapped, or
null if this map contains no mapping for the
key. |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings.
|
Enumeration<K> |
keys()
Returns an enumeration of the keys in this table.
|
Set<K> |
keySet() |
V |
put(K key,
V value)
Maps the specified key to the specified value in this table.
|
void |
putAll(Map<? extends K,? extends V> m)
Copies all of the mappings from the specified map to this one.
|
V |
putIfAbsent(K key,
V value) |
V |
remove(Object key)
Removes the key (and its corresponding value) from this map.
|
boolean |
remove(Object key,
Object value) |
V |
replace(K key,
V value) |
boolean |
replace(K key,
V oldValue,
V newValue) |
int |
size()
Returns the number of key-value mappings in this map.
|
Collection<V> |
values() |
equals, hashCode, toString
public ConcurrentIdentityHashMap(int initialCapacity, float loadFactor, int concurrencyLevel)
initialCapacity
- the initial capacity. The implementation performs internal sizing to accommodate this many
elements.loadFactor
- the load factor threshold, used to control resizing. Resizing may be performed when the average
number of elements per bin exceeds this threshold.concurrencyLevel
- the estimated number of concurrently updating threads. The implementation performs
internal sizing to try to accommodate this many threads.IllegalArgumentException
- if the initial capacity is negative or the load factor or concurrencyLevel are
nonpositive.public ConcurrentIdentityHashMap(int initialCapacity, float loadFactor)
initialCapacity
- The implementation performs internal sizing to accommodate this many elements.loadFactor
- the load factor threshold, used to control resizing. Resizing may be performed when the average
number of elements per bin exceeds this threshold.IllegalArgumentException
- if the initial capacity of elements is negative or the load factor is
nonpositivepublic ConcurrentIdentityHashMap(int initialCapacity)
initialCapacity
- the initial capacity. The implementation performs internal sizing to accommodate this many
elements.IllegalArgumentException
- if the initial capacity of elements is negative.public ConcurrentIdentityHashMap()
public ConcurrentIdentityHashMap(Map<? extends K,? extends V> m)
m
- the mappublic boolean isEmpty()
public int size()
public V get(Object key)
null
if this map contains no mapping for the
key.
More formally, if this map contains a mapping from a key k
to a value v
such that
key.equals(k)
, then this method returns v
; otherwise it returns null
. (There can be at
most one such mapping.)
get
在接口中 Map<K,V>
get
在类中 AbstractMap<K,V>
NullPointerException
- if the specified key is nullpublic boolean containsKey(Object key)
containsKey
在接口中 Map<K,V>
containsKey
在类中 AbstractMap<K,V>
key
- possible keyNullPointerException
- if the specified key is nullpublic boolean containsValue(Object value)
containsValue
在接口中 Map<K,V>
containsValue
在类中 AbstractMap<K,V>
value
- value whose presence in this map is to be testedNullPointerException
- if the specified value is nullpublic boolean contains(Object value)
public V put(K key, V value)
The value can be retrieved by calling the get method with a key that is equal to the original key.
put
在接口中 Map<K,V>
put
在类中 AbstractMap<K,V>
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keyNullPointerException
- if the specified key or value is nullpublic V putIfAbsent(K key, V value)
putIfAbsent
在接口中 ConcurrentMap<K,V>
NullPointerException
- if the specified key or value is nullpublic final void putAll(Map<? extends K,? extends V> m)
public V remove(Object key)
remove
在接口中 Map<K,V>
remove
在类中 AbstractMap<K,V>
key
- the key that needs to be removedNullPointerException
- if the specified key is nullpublic boolean remove(Object key, Object value)
remove
在接口中 ConcurrentMap<K,V>
NullPointerException
- if the specified key is nullpublic boolean replace(K key, V oldValue, V newValue)
replace
在接口中 ConcurrentMap<K,V>
NullPointerException
- if any of the arguments are nullpublic V replace(K key, V value)
replace
在接口中 ConcurrentMap<K,V>
NullPointerException
- if the specified key or value is nullpublic void clear()
public Collection<V> values()
public Enumeration<K> keys()
keySet()
public Enumeration<V> elements()
values()
Copyright © 2012-2013 Alibaba Group. All Rights Reserved.