java.util.concurrent.ConcurrentHashMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dragome-js-jre Show documentation
Show all versions of dragome-js-jre Show documentation
Dragome SDK module: js-jre
The newest version!
package java.util.concurrent;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
public class ConcurrentHashMap extends HashMap implements ConcurrentMap, Serializable
{
public ConcurrentHashMap()
{
super();
}
public ConcurrentHashMap(int i)
{
super(i);
}
public ConcurrentHashMap(Map extends K, ? extends V> m)
{
super(m);
}
public ConcurrentHashMap(int initialCapacity, float loadFactor, int concurrencyLevel)
{
super(initialCapacity);
}
private static final long serialVersionUID= 7249069246763182397L;
public V putIfAbsent(K key, V value)
{
if (!containsKey(key))
return put(key, value);
else
return get(key);
}
public boolean remove(Object key, Object value)
{
if (containsKey(key) && get(key).equals(value))
{
remove(key);
return true;
}
else
return false;
}
public boolean replace(K key, V oldValue, V newValue)
{
if (containsKey(key) && get(key).equals(oldValue))
{
put(key, newValue);
return true;
}
else
return false;
}
public V replace(K key, V value)
{
if (containsKey(key))
{
return put(key, value);
}
else
return null;
}
}