public class LongConcurrentHashMap<V> extends LongMap<V> implements Serializable
LongMap.LongMapIterator<V>
Modifier and Type | Field and Description |
---|---|
protected long |
hashSalt
Salt added to keys before hashing, so it is harder to trigger hash collision attack.
|
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(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,
Object value) |
V |
replace(long key,
V value) |
boolean |
replace(long key,
V oldValue,
V newValue) |
int |
size()
Returns the number of key-value mappings in this map.
|
Iterator<V> |
valuesIterator() |
protected final long hashSalt
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.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.IllegalArgumentException
- if the initial capacity of
elements is negative.public LongConcurrentHashMap()
public boolean isEmpty()
isEmpty
in class LongMap<V>
LongMap.size()
public int size()
public 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.)
get
in class LongMap<V>
key
- the key.null
if no mapping for the specified key is found.NullPointerException
- if the specified key is nullpublic boolean containsKey(long key)
key
- possible keyNullPointerException
- if the specified key is nullpublic boolean containsValue(Object value)
value
- value whose presence in this map is to be testedNullPointerException
- 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 keyNullPointerException
- if the specified key or value is nullpublic V putIfAbsent(long key, V value)
NullPointerException
- if the specified key or value is nullpublic V remove(long key)
remove
in class LongMap<V>
key
- the key that needs to be removedNullPointerException
- if the specified key is nullpublic boolean remove(long key, Object value)
NullPointerException
- if the specified key is nullpublic boolean replace(long key, V oldValue, V newValue)
NullPointerException
- if any of the arguments are nullpublic V replace(long key, V value)
NullPointerException
- if the specified key or value is nullpublic void clear()
clear
in class LongMap<V>
LongMap.isEmpty()
,
LongMap.size()
Copyright © 2019. All rights reserved.