/** * {@inheritDoc} * * @throws NullPointerException if any of the arguments are null */ @Override public boolean replace(K key, V oldValue, V newValue) { if ( key == null || oldValue == null || newValue == null ) { throw new NullPointerException(); } int hash = hashOf( key ); return segmentFor( hash ).replace( key, hash, oldValue, newValue ); }
/** * {@inheritDoc} * * @throws NullPointerException if the specified key is null */ @Override public boolean remove(Object key, Object value) { if ( key == null || value == null ) { return false; } int hash = hashOf( key ); return segmentFor( hash ).remove( key, hash, value, false ) != null; }
/** * {@inheritDoc} * * @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 V putIfAbsent(K key, V value) { if ( key == null || value == null ) { return null; } int hash = hashOf( key ); return segmentFor( hash ).put( key, hash, value, true ); }
/** * {@inheritDoc} * * @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 V replace(K key, V value) { if ( key == null || value == null ) { return null; } int hash = hashOf( key ); return segmentFor( hash ).replace( key, hash, value ); }
/** * Returns the value to which the specified key is mapped, * or {@code null} if this map contains no mapping for the key. * <p/> * <p>More formally, if this map contains a mapping from a key * {@code k} to a value {@code v} such that {@code key.equals(k)}, * then this method returns {@code v}; otherwise it returns * {@code null}. (There can be at most one such mapping.) * * @throws NullPointerException if the specified key is null */ @Override public V get(Object key) { if ( key == null ) { return null; } int hash = hashOf( key ); return segmentFor( hash ).get( key, hash ); }
/** * Tests if the specified object is a key in this table. * * @param key possible key * * @return <tt>true</tt> if and only if the specified object * is a key in this table, as determined by the * <tt>equals</tt> method; <tt>false</tt> otherwise. * * @throws NullPointerException if the specified key is null */ @Override public boolean containsKey(Object key) { if ( key == null ) { return false; } int hash = hashOf( key ); return segmentFor( hash ).containsKey( key, hash ); }
/** * Removes the key (and its corresponding value) from this map. * This method does nothing if the key is not in the map. * * @param key the key that needs to be removed * * @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 V remove(Object key) { if ( key == null ) { return null; } int hash = hashOf( key ); return segmentFor( hash ).remove( key, hash, null, false ); }
/** * Maps the specified key to the specified value in this table. * Neither the key nor the value can be null. * <p/> * <p> The value can be retrieved by calling the <tt>get</tt> method * with a key that is equal to the original key. * * @param key key with which the specified value is to be associated * @param value 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 V put(K key, V value) { if ( key == null || value == null ) { return null; } int hash = hashOf( key ); return segmentFor( hash ).put( key, hash, value, false ); }
/** * {@inheritDoc} * * @throws NullPointerException if any of the arguments are null */ @Override public boolean replace(K key, V oldValue, V newValue) { if ( key == null || oldValue == null || newValue == null ) { throw new NullPointerException(); } int hash = hashOf( key ); return segmentFor( hash ).replace( key, hash, oldValue, newValue ); }
/** * {@inheritDoc} * * @throws NullPointerException if the specified key is null */ @Override public boolean remove(Object key, Object value) { if ( key == null || value == null ) { return false; } int hash = hashOf( key ); return segmentFor( hash ).remove( key, hash, value, false ) != null; }
/** * {@inheritDoc} * * @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 V putIfAbsent(K key, V value) { if ( key == null || value == null ) { return null; } int hash = hashOf( key ); return segmentFor( hash ).put( key, hash, value, true ); }
/** * {@inheritDoc} * * @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 V replace(K key, V value) { if ( key == null || value == null ) { return null; } int hash = hashOf( key ); return segmentFor( hash ).replace( key, hash, value ); }
/** * Removes the key (and its corresponding value) from this map. * This method does nothing if the key is not in the map. * * @param key the key that needs to be removed * * @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 V remove(Object key) { if ( key == null ) { return null; } int hash = hashOf( key ); return segmentFor( hash ).remove( key, hash, null, false ); }
/** * Returns the value to which the specified key is mapped, * or {@code null} if this map contains no mapping for the key. * <p/> * <p>More formally, if this map contains a mapping from a key * {@code k} to a value {@code v} such that {@code key.equals(k)}, * then this method returns {@code v}; otherwise it returns * {@code null}. (There can be at most one such mapping.) * * @throws NullPointerException if the specified key is null */ @Override public V get(Object key) { if ( key == null ) { return null; } int hash = hashOf( key ); return segmentFor( hash ).get( key, hash ); }
/** * Tests if the specified object is a key in this table. * * @param key possible key * * @return <tt>true</tt> if and only if the specified object * is a key in this table, as determined by the * <tt>equals</tt> method; <tt>false</tt> otherwise. * * @throws NullPointerException if the specified key is null */ @Override public boolean containsKey(Object key) { if ( key == null ) { return false; } int hash = hashOf( key ); return segmentFor( hash ).containsKey( key, hash ); }
/** * Maps the specified key to the specified value in this table. * Neither the key nor the value can be null. * <p/> * <p> The value can be retrieved by calling the <tt>get</tt> method * with a key that is equal to the original key. * * @param key key with which the specified value is to be associated * @param value 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 V put(K key, V value) { if ( key == null || value == null ) { return null; } int hash = hashOf( key ); return segmentFor( hash ).put( key, hash, value, false ); }