/** * Version of remove with boolean return. Needed by view classes */ boolean removep(Object key) { return doRemove(key, null) != null; }
/** * Removes the mapping for this key from this Map if present. * * @param key key for which mapping should be removed * @return previous value associated with specified key, or <tt>null</tt> * if there was no mapping for key. * * @throws ClassCastException if the key cannot be compared with the keys * currently in the map. * @throws NullPointerException if the key is <tt>null</tt>. */ public V remove(Object key) { return doRemove(key, null); }
/** * Remove entry for key only if currently mapped to given value. * Acts as * <pre> * if ((map.containsKey(key) && map.get(key).equals(value)) { * map.remove(key); * return true; * } else return false; * </pre> * except that the action is performed atomically. * @param key key with which the specified value is associated. * @param value value associated with the specified key. * @return true if the value was removed, false otherwise * @throws ClassCastException if the key cannot be compared with the keys * currently in the map. * @throws NullPointerException if the key or value are <tt>null</tt>. */ public boolean remove(Object key, Object value) { if (value == null) throw new NullPointerException(); return doRemove(key, value) != null; }
/** * Find and remove least element of subrange. * @param least minimum allowed key value * @param fence key greater than maximum allowed key value * @param keyOnly if true return key, else return SnapshotEntry * @return least Key or Entry, or <tt>null</tt> if no such */ Object removeFirstEntryOfSubrange(K least, K fence, boolean keyOnly) { for (;;) { Node<K,V> n = findCeiling(least); if (n == null) return null; K k = n.key; if (fence != null && compare(k, fence) >= 0) return null; V v = doRemove(k, null); if (v != null) return (keyOnly)? k : new SnapshotEntry<K,V>(k, v); } }
/** * Find and remove greatest element of subrange. * @param least minimum allowed key value * @param fence key greater than maximum allowed key value * @param keyOnly if true return key, else return SnapshotEntry * @return least Key or Entry, or <tt>null</tt> if no such */ Object removeLastEntryOfSubrange(K least, K fence, boolean keyOnly) { for (;;) { Node<K,V> n = findLower(fence); if (n == null) return null; K k = n.key; if (least != null && compare(k, least) < 0) return null; V v = doRemove(k, null); if (v != null) return (keyOnly)? k : new SnapshotEntry<K,V>(k, v); } }