K - the key typeV - the value typepublic class RapidFastMap<K,V> extends Object implements Cloneable, Serializable
RapidFastMap which provides a fast map with concurrency. A thread
safe implementation is added on top of the Hash Map mechanism.| Constructor and Description |
|---|
RapidFastMap()
Instantiates a new empty rapid fast map with a default initial capacity,
load factor, and concurrencyLevel.
|
RapidFastMap(Map<? extends K,? extends V> tempMap)
Instantiates a new rapid fast map with the given map elements and its
capacity.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all mappings from this map.
|
boolean |
containsKey(K key)
Tests if the specified object is a key in this table.
|
boolean |
containsValue(V value)
Returns true if this map maps one or more keys to the specified
value.
|
Collection<V> |
elements()
Returns an enumeration of the values in this table.
|
Set<Map.Entry<K,V>> |
entrySet()
Returns a collection view of the mappings contained in this map.
|
boolean |
equals(Object o)
Compares the specified object with this map for equality.
|
V |
get(K key)
Returns the value to which the specified key is mapped in this table.
|
Map<K,V> |
getAsMap()
Returns this Object as
Map. |
int |
hashCode()
Returns the hash code value for this map.
|
boolean |
isEmpty()
Returns true if this map contains no key-value mappings.
|
Set<K> |
keys()
Returns an enumeration of the keys in this table.
|
Set<K> |
keySet()
Returns a set view of the keys contained in this map.
|
V |
put(K key,
V value)
Maps the specified key to the specified value in this
table.
|
void |
putAll(Map<? extends K,? extends V> t)
Copies all of the mappings from the specified map to this one.
|
V |
putIfAbsent(K key,
V value)
If the specified key is not already associated with a value, associate it
with the given value.
|
V |
remove(K key)
Removes the key (and its corresponding value) from this table.
|
boolean |
remove(K key,
V value)
Remove entry for key only if currently mapped to given value.
|
V |
replace(K key,
V value)
Replace entry for key only if currently mapped to some value.
|
boolean |
replace(K key,
V oldValue,
V newValue)
Replace entry for key only if currently mapped to given value.
|
int |
size()
Returns the number of key-value mappings in this map.
|
String |
toString()
Returns a string representation of this map.
|
Collection<V> |
values()
Returns a collection view of the values contained in this map.
|
public RapidFastMap()
public boolean isEmpty()
This implementation returns size() == 0.
public int size()
This implementation returns entrySet().size().
public V get(K key)
key - a key in the table.NullPointerException - if the key is null.public boolean containsKey(K key)
key - possible key.NullPointerException - if the key is null.public boolean containsValue(V value)
value - value whose presence in this map is to be tested.NullPointerException - if the value is null.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.
key - the table key.value - the value.NullPointerException - if the key or value is null.public V putIfAbsent(K key, V value)
if (!map.containsKey(key))
return map.put(key, value);
else
return map.get(key);
Except that the action is performed atomically.key - key with which the specified value is to be associated.value - value to be associated with the specified key.NullPointerException - if the specified key or value is null.public void putAll(Map<? extends K,? extends V> t)
t - Mappings to be stored in this map.public V remove(K key)
key - the key that needs to be removed.NullPointerException - if the key is null.public boolean remove(K key, V value)
if (map.get(key).equals(value))
{
map.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 associated with the specified key.NullPointerException - if the specified key is null.public boolean replace(K key, V oldValue, V newValue)
if (map.get(key).equals(oldValue))
{
map.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.NullPointerException - if the specified key or values are null.public V replace(K key, V value)
if ((map.containsKey(key)) {
return map.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.NullPointerException - if the specified key or value is null.public void clear()
public Set<K> keySet()
ConcurrentModificationException, and guarantees to
traverse elements as they existed upon construction of the iterator, and
may (but is not guaranteed to) reflect any modifications subsequent to
construction.public Collection<V> values()
ConcurrentModificationException, and guarantees to
traverse elements as they existed upon construction of the iterator, and
may (but is not guaranteed to) reflect any modifications subsequent to
construction.public Set<Map.Entry<K,V>> entrySet()
ConcurrentModificationException, and guarantees to
traverse elements as they existed upon construction of the iterator, and
may (but is not guaranteed to) reflect any modifications subsequent to
construction.public Set<K> keys()
keySet()public Collection<V> elements()
values()public boolean equals(Object o)
This implementation first checks if the specified object is this map; if so it returns true. Then, it checks if the specified object is a map whose size is identical to the size of this set; if not, it returns false. If so, it iterates over this map's entrySet collection, and checks that the specified map contains each mapping that this map contains. If the specified map fails to contain such a mapping, false is returned. If the iteration completes, true is returned.
public int hashCode()
This implementation iterates over entrySet(), calling hashCode on each element (entry) in the Collection, and adding up the results.
hashCode in class ObjectMap.Entry.hashCode(),
Object.hashCode(),
Object.equals(Object),
Set.equals(Object)public String toString()
This implementation creates an empty string buffer, appends a left brace, and iterates over the map's entrySet view, appending the string representation of each map.entry in turn. After appending each entry except the last, the string ", " is appended. Finally a right brace is appended. A string is obtained from the stringBuffer, and returned.
Copyright © 2016 utils4j. All Rights Reserved.