public class LongConcurrentHashMap<V> extends LongMap<V> implements java.io.Serializable
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
LongConcurrentHashMap.HashEntry<V>
LongConcurrentHashMap list entry.
|
(package private) class |
LongConcurrentHashMap.HashIterator |
(package private) class |
LongConcurrentHashMap.KeyIterator |
(package private) class |
LongConcurrentHashMap.MapIterator |
(package private) static class |
LongConcurrentHashMap.Segment<V>
Segments are specialized versions of hash tables.
|
(package private) class |
LongConcurrentHashMap.ValueIterator |
LongMap.LongMapIterator<V>| Modifier and Type | Field and Description |
|---|---|
(package private) static int |
DEFAULT_CONCURRENCY_LEVEL
The default concurrency level for this table, used when not
otherwise specified in a constructor.
|
(package private) static int |
DEFAULT_INITIAL_CAPACITY
The default initial capacity for this table,
used when not otherwise specified in a constructor.
|
(package private) static float |
DEFAULT_LOAD_FACTOR
The default load factor for this table, used when not
otherwise specified in a constructor.
|
protected long |
hashSalt
Salt added to keys before hashing, so it is harder to trigger hash collision attack.
|
(package private) static int |
MAX_SEGMENTS
The maximum number of segments to allow; used to bound
constructor arguments.
|
(package private) static int |
MAXIMUM_CAPACITY
The maximum capacity, used if a higher value is implicitly
specified by either of the constructors with arguments.
|
(package private) static int |
RETRIES_BEFORE_LOCK
Number of unsynchronized retries in size and containsValue
methods before resorting to locking.
|
(package private) int |
segmentMask
Mask value for indexing into segments.
|
(package private) LongConcurrentHashMap.Segment<V>[] |
segments
The segments, each of which is a specialized hash table
|
(package private) int |
segmentShift
Shift value for indexing within segments.
|
private static long |
serialVersionUID |
| Constructor and Description |
|---|
LongConcurrentHashMap()
Creates a new, empty map with a default initial capacity (16),
load factor (0.75) and concurrencyLevel (16).
|
LongConcurrentHashMap(int initialCapacity)
Creates a new, empty map with the specified initial capacity,
and with default load factor (0.75) and concurrencyLevel (16).
|
LongConcurrentHashMap(int initialCapacity,
float loadFactor,
int concurrencyLevel)
Creates a new, empty map with the specified initial
capacity, load factor and concurrency level.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all of the mappings from this map.
|
boolean |
containsKey(long key)
Tests if the specified object is a key in this table.
|
boolean |
containsValue(java.lang.Object value)
Returns true if this map maps one or more keys to the
specified value.
|
V |
get(long 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.
|
LongMap.LongMapIterator<V> |
longMapIterator() |
V |
put(long key,
V value)
Maps the specified key to the specified value in this table.
|
V |
putIfAbsent(long key,
V value) |
V |
remove(long key)
Removes the key (and its corresponding value) from this map.
|
boolean |
remove(long key,
java.lang.Object value) |
V |
replace(long key,
V value) |
boolean |
replace(long key,
V oldValue,
V newValue) |
(package private) LongConcurrentHashMap.Segment<V> |
segmentFor(int hash)
Returns the segment that should be used for key with given hash
|
int |
size()
Returns the number of key-value mappings in this map.
|
java.util.Iterator<V> |
valuesIterator() |
private static final long serialVersionUID
static final int DEFAULT_INITIAL_CAPACITY
protected final long hashSalt
static final float DEFAULT_LOAD_FACTOR
static final int DEFAULT_CONCURRENCY_LEVEL
static final int MAXIMUM_CAPACITY
static final int MAX_SEGMENTS
static final int RETRIES_BEFORE_LOCK
final int segmentMask
final int segmentShift
final LongConcurrentHashMap.Segment<V>[] segments
public LongConcurrentHashMap(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.java.lang.IllegalArgumentException - if the initial capacity is
negative or the load factor or concurrencyLevel are
nonpositive.public LongConcurrentHashMap(int initialCapacity)
initialCapacity - the initial capacity. The implementation
performs internal sizing to accommodate this many elements.java.lang.IllegalArgumentException - if the initial capacity of
elements is negative.public LongConcurrentHashMap()
final LongConcurrentHashMap.Segment<V> segmentFor(int hash)
hash - the hash code for the keypublic boolean isEmpty()
isEmpty in class LongMap<V>LongMap.size()public int size()
public java.util.Iterator<V> valuesIterator()
valuesIterator in class LongMap<V>public LongMap.LongMapIterator<V> longMapIterator()
longMapIterator in class LongMap<V>public V get(long 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 keys such that key.equals(k),
then this method returns keys; otherwise it returns
null. (There can be at most one such mapping.)
public boolean containsKey(long key)
key - possible keyjava.lang.NullPointerException - if the specified key is nullpublic boolean containsValue(java.lang.Object value)
value - value whose presence in this map is to be testedjava.lang.NullPointerException - if the specified value is nullpublic V put(long key, V value)
The value can be retrieved by calling the get method with a key that is equal to the original key.
put in class LongMap<V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keyjava.lang.NullPointerException - if the specified key or value is nullpublic V putIfAbsent(long key, V value)
java.lang.NullPointerException - if the specified key or value is nullpublic V remove(long key)
public boolean remove(long key,
java.lang.Object value)
java.lang.NullPointerException - if the specified key is nullpublic boolean replace(long key,
V oldValue,
V newValue)
java.lang.NullPointerException - if any of the arguments are nullpublic V replace(long key, V value)
java.lang.NullPointerException - if the specified key or value is nullpublic void clear()
clear in class LongMap<V>LongMap.isEmpty(),
LongMap.size()