public class LongKeyCache<V>
extends java.lang.Object
Constructor and Description |
---|
LongKeyCache() |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(long key) |
V |
get(long key) |
LongSet |
keySet() |
V |
put(long key,
V value) |
V |
putIfAbsent(long key,
V value)
If the specified key is not already associated with a value, associate it
with the given value.
|
V |
remove(long key) |
boolean |
remove(long key,
V value)
Removes the entry for a key only if currently mapped to a given value.
|
V |
replace(long key,
V value)
Replaces the entry for a key only if currently mapped to some value.
|
boolean |
replace(long key,
V oldValue,
V newValue)
Replaces the entry for a key only if currently mapped to a given value.
|
public void clear()
public boolean containsKey(long key)
public LongSet keySet()
public V get(long key)
public V putIfAbsent(long key, V value)
if (!cache.containsKey(key)) return cache.put(key, value);
else return cache.get(key);
except that the action is performed atomically.public V replace(long key, V value)
if (cache.containsKey(key)) {
return cache.put(key, value);
} else return null;
except that the action is performed atomically.key
- key with which the specified value is associated.value
- value to be associated with the specified key.public boolean replace(long key, V oldValue, V newValue)
if (cache.containsKey(key) && cache.get(key).equals(oldValue)) {
cache.put(key, newValue);
return true;
} else return false;
except that the action is performed atomically.key
- key with which the specified value is associated.oldValue
- value expected to be associated with the specified key.newValue
- value to be associated with the specified key.public V remove(long key)
public boolean remove(long key, V value)
if (cache.containsKey(key) && cache.get(key).equals(value)) {
cache.remove(key);
return true;
} else return false;
except that the action is performed atomically.key
- key with which the specified value is associated.value
- value expected to be associated with the specified key.