/** Removes the key (and its corresponding value) from this map. * This method does nothing if the key is not in the map. * @return the previous value associated with <tt>key</tt>, or * <tt>null</tt> if there was no mapping for <tt>key</tt> * @throws NullPointerException if the specified key is null */ @Override public TypeV remove ( Object key ) { return putIfMatch( key,TOMBSTONE, NO_MATCH_OLD); }
public final TypeV putIfMatchAllowNull( Object key, Object newVal, Object oldVal ) { if( oldVal == null ) oldVal = TOMBSTONE; if( newVal == null ) newVal = TOMBSTONE; final TypeV res = (TypeV)putIfMatch( this, _kvs, key, newVal, oldVal ); assert !(res instanceof Prime); //assert res != null; return res == TOMBSTONE ? null : res; }
/** Maps the specified key to the specified value in the table. Neither key * nor value can be null. * <p> The value can be retrieved by calling {@link #get} with a key that is * equal to the original key. * @param key key with which the specified value is to be associated * @param val value to be associated with the specified key * @return the previous value associated with <tt>key</tt>, or * <tt>null</tt> if there was no mapping for <tt>key</tt> * @throws NullPointerException if the specified key or value is null */ @Override public TypeV put ( TypeK key, TypeV val ) { return putIfMatch( key, val, NO_MATCH_OLD); }
/** Atomically, do a {@link #put} if-and-only-if the key is not mapped. * Useful to ensure that only a single mapping for the key exists, even if * many threads are trying to create the mapping in parallel. * @return the previous value associated with the specified key, * or <tt>null</tt> if there was no mapping for the key * @throws NullPointerException if the specified key or value is null */ @Override public TypeV putIfAbsent( TypeK key, TypeV val ) { return putIfMatch( key, val, TOMBSTONE ); }
/** Atomically do a <code>put(key,val)</code> if-and-only-if the key is * mapped to some value already. * @throws NullPointerException if the specified key or value is null */ @Override public TypeV replace ( TypeK key, TypeV val ) { return putIfMatch( key, val,MATCH_ANY ); }
/** Atomically do a {@link #remove(Object)} if-and-only-if the key is mapped * to a value which is <code>equals</code> to the given value. * @throws NullPointerException if the specified key or value is null */ public boolean remove ( Object key,Object val ) { return Objects.equals(putIfMatch( key,TOMBSTONE, val ), val); }
/** Atomically do a <code>put(key,newValue)</code> if-and-only-if the key is * mapped a value which is <code>equals</code> to <code>oldValue</code>. * @throws NullPointerException if the specified key or value is null */ @Override public boolean replace ( TypeK key, TypeV oldValue, TypeV newValue ) { return Objects.equals(putIfMatch( key, newValue, oldValue ), oldValue); }
/** Atomically replace newVal for oldVal, returning the value that existed * there before. If the oldVal matches the returned value, then newVal was * inserted, otherwise not. * @return the previous value associated with the specified key, * or <tt>null</tt> if there was no mapping for the key * @throws NullPointerException if the key or either value is null */ public final TypeV putIfMatch( Object key, Object newVal, Object oldVal ) { if (oldVal == null || newVal == null) throw new NullPointerException(); final Object res = putIfMatch( this, _kvs, key, newVal, oldVal ); assert !(res instanceof Prime); assert res != null; return res == TOMBSTONE ? null : (TypeV)res; }
return putIfMatch(topmap,newkvs,key,putval,expVal); return putIfMatch(topmap,chm.copy_slot_and_check(topmap,kvs,idx,expVal),key,putval,expVal); return putIfMatch(topmap,chm.copy_slot_and_check(topmap,kvs,idx,expVal),key,putval,expVal);
/** Atomically, do a {@link #put} if-and-only-if the key is not mapped. * Useful to ensure that only a single mapping for the key exists, even if * many threads are trying to create the mapping in parallel. * @return the previous value associated with the specified key, * or <tt>null</tt> if there was no mapping for the key * @throws NullPointerException if the specified key or value is null */ @Override public TypeV putIfAbsent( TypeK key, TypeV val ) { return putIfMatch( key, val, TOMBSTONE ); }
/** Atomically do a <code>put(key,val)</code> if-and-only-if the key is * mapped to some value already. * @throws NullPointerException if the specified key or value is null */ @Override public TypeV replace ( TypeK key, TypeV val ) { return putIfMatch( key, val,MATCH_ANY ); }
/** Maps the specified key to the specified value in the table. Neither key * nor value can be null. * <p> The value can be retrieved by calling {@link #get} with a key that is * equal to the original key. * @param key key with which the specified value is to be associated * @param val value to be associated with the specified key * @return the previous value associated with <tt>key</tt>, or * <tt>null</tt> if there was no mapping for <tt>key</tt> * @throws NullPointerException if the specified key or value is null */ @Override public TypeV put ( TypeK key, TypeV val ) { return putIfMatch( key, val, NO_MATCH_OLD); }
/** Removes the key (and its corresponding value) from this map. * This method does nothing if the key is not in the map. * @return the previous value associated with <tt>key</tt>, or * <tt>null</tt> if there was no mapping for <tt>key</tt> * @throws NullPointerException if the specified key is null */ @Override public TypeV remove ( Object key ) { return putIfMatch( key,TOMBSTONE, NO_MATCH_OLD); }
public final TypeV putIfMatchAllowNull( Object key, Object newVal, Object oldVal ) { if( oldVal == null ) oldVal = TOMBSTONE; if( newVal == null ) newVal = TOMBSTONE; final TypeV res = (TypeV)putIfMatch( this, _kvs, key, newVal, oldVal ); assert !(res instanceof Prime); //assert res != null; return res == TOMBSTONE ? null : res; }
/** Atomically do a <code>put(key,newValue)</code> if-and-only-if the key is * mapped a value which is <code>equals</code> to <code>oldValue</code>. * @throws NullPointerException if the specified key or value is null */ @Override public boolean replace ( TypeK key, TypeV oldValue, TypeV newValue ) { return Objects.equals(putIfMatch( key, newValue, oldValue ), oldValue); }
/** Atomically do a {@link #remove(Object)} if-and-only-if the key is mapped * to a value which is <code>equals</code> to the given value. * @throws NullPointerException if the specified key or value is null */ public boolean remove ( Object key,Object val ) { return Objects.equals(putIfMatch( key,TOMBSTONE, val ), val); }
/** Atomically replace newVal for oldVal, returning the value that existed * there before. If the oldVal matches the returned value, then newVal was * inserted, otherwise not. * @return the previous value associated with the specified key, * or <tt>null</tt> if there was no mapping for the key * @throws NullPointerException if the key or either value is null */ public final TypeV putIfMatch( Object key, Object newVal, Object oldVal ) { if (oldVal == null || newVal == null) throw new NullPointerException(); final Object res = putIfMatch( this, _kvs, key, newVal, oldVal ); assert !(res instanceof Prime); assert res != null; return res == TOMBSTONE ? null : (TypeV)res; }
return putIfMatch(topmap,newkvs,key,putval,expVal); return putIfMatch(topmap,chm.copy_slot_and_check(topmap,kvs,idx,expVal),key,putval,expVal); return putIfMatch(topmap,chm.copy_slot_and_check(topmap,kvs,idx,expVal),key,putval,expVal);