/** * Replace entry for key only if currently mapped to some value. Acts as * <pre> * if ((map.containsKey(key)) { * return map.put(key, value); * } else return null; * </pre> * except that the action is performed atomically. * * @param key key with which the specified value is associated. * @param value value to be associated with the specified key. * * @return previous value associated with specified key, or <tt>null</tt> if * there was no mapping for key. * * @throws NullPointerException if the specified key or value is * <tt>null</tt>. */ public V replace(K key, V value) { if (value == null) { throw new NullPointerException(); } int hash = hash(key, null, null, null); return segmentFor(hash).replace(key, null, null, null, hash, value); }
/** * Replace entry for key only if currently mapped to some value. Acts as * <pre> * if ((map.containsKey(key)) { * return map.put(key, value); * } else return null; * </pre> * except that the action is performed atomically. * * @param key key with which the specified value is associated. * @param value value to be associated with the specified key. * * @return previous value associated with specified key, or <tt>null</tt> if * there was no mapping for key. * * @throws NullPointerException if the specified key or value is * <tt>null</tt>. */ public V replace(K key, V value) { if (value == null) { throw new NullPointerException(); } int hash = hash(key, null, null, null); return segmentFor(hash).replace(key, null, null, null, hash, value); }
/** * Replace entry for key only if currently mapped to given value. Acts as * <pre> * if (map.get(key).equals(oldValue)) { * map.put(key, newValue); * return true; * } else return false; * </pre> * except that the action is performed atomically. * * @param key key with which the specified value is associated. * @param oldValue value expected to be associated with the specified key. * @param newValue value to be associated with the specified key. * * @return true if the value was replaced * * @throws NullPointerException if the specified key or values are * <tt>null</tt>. */ public boolean replace(K key, V oldValue, V newValue) { if (oldValue == null || newValue == null) { throw new NullPointerException(); } int hash = hash(key, null, null, null); return segmentFor(hash) .replace(key, null, null, null, hash, oldValue, newValue); }
/** * Replace entry for key only if currently mapped to given value. Acts as * <pre> * if (map.get(key).equals(oldValue)) { * map.put(key, newValue); * return true; * } else return false; * </pre> * except that the action is performed atomically. * * @param key key with which the specified value is associated. * @param oldValue value expected to be associated with the specified key. * @param newValue value to be associated with the specified key. * * @return true if the value was replaced * * @throws NullPointerException if the specified key or values are * <tt>null</tt>. */ public boolean replace(K key, V oldValue, V newValue) { if (oldValue == null || newValue == null) { throw new NullPointerException(); } int hash = hash(key, null, null, null); return segmentFor(hash) .replace(key, null, null, null, hash, oldValue, newValue); }
/** * Replace entry for key only if currently mapped to some value. Acts as * <pre> * if ((map.containsKey(key)) { * return map.put(key, value); * } else return null; * </pre> * except that the action is performed atomically. * * @param key key with which the specified value is associated. * @param value value to be associated with the specified key. * * @return previous value associated with specified key, or <tt>null</tt> if * there was no mapping for key. * * @throws NullPointerException if the specified key or value is * <tt>null</tt>. */ public V replace(K key, V value) { if (value == null) { throw new NullPointerException(); } int hash = hash(key, null, null, null); return segmentFor(hash).replace(key, null, null, null, hash, value); }
/** * Replace entry for key only if currently mapped to given value. Acts as * <pre> * if (map.get(key).equals(oldValue)) { * map.put(key, newValue); * return true; * } else return false; * </pre> * except that the action is performed atomically. * * @param key key with which the specified value is associated. * @param oldValue value expected to be associated with the specified key. * @param newValue value to be associated with the specified key. * * @return true if the value was replaced * * @throws NullPointerException if the specified key or values are * <tt>null</tt>. */ public boolean replace(K key, V oldValue, V newValue) { if (oldValue == null || newValue == null) { throw new NullPointerException(); } int hash = hash(key, null, null, null); return segmentFor(hash) .replace(key, null, null, null, hash, oldValue, newValue); }
/** * Replace entry for key only if currently mapped to given value. Acts as * <pre> * if (map.get(key).equals(oldValue)) { * map.put(key, newValue); * return true; * } else return false; * </pre> * except that the action is performed atomically. * * @param key key with which the specified value is associated. * @param oldValue value expected to be associated with the specified key. * @param newValue value to be associated with the specified key. * * @return true if the value was replaced * * @throws NullPointerException if the specified key or values are * <tt>null</tt>. */ public boolean replace(K key, V oldValue, V newValue) { if (oldValue == null || newValue == null) { throw new NullPointerException(); } int hash = hash(key, null, null, null); return segmentFor(hash) .replace(key, null, null, null, hash, oldValue, newValue); }
/** * Replace entry for key only if currently mapped to some value. Acts as * <pre> * if ((map.containsKey(key)) { * return map.put(key, value); * } else return null; * </pre> * except that the action is performed atomically. * * @param key key with which the specified value is associated. * @param value value to be associated with the specified key. * * @return previous value associated with specified key, or <tt>null</tt> if * there was no mapping for key. * * @throws NullPointerException if the specified key or value is * <tt>null</tt>. */ public V replace(K key, V value) { if (value == null) { throw new NullPointerException(); } int hash = hash(key, null, null, null); return segmentFor(hash).replace(key, null, null, null, hash, value); }