Removes the entry for key if it exists. @return the previous value mapped by key.
(K key)
| 193 | * @return the previous value mapped by {@code key}. |
| 194 | */ |
| 195 | public final V remove(K key) { |
| 196 | if (key == null) { |
| 197 | throw new NullPointerException("key == null"); |
| 198 | } |
| 199 | |
| 200 | V previous; |
| 201 | synchronized (this) { |
| 202 | previous = map.remove(key); |
| 203 | if (previous != null) { |
| 204 | size -= safeSizeOf(key, previous); |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | if (previous != null) { |
| 209 | entryRemoved(false, key, previous, null); |
| 210 | } |
| 211 | |
| 212 | return previous; |
| 213 | } |
| 214 | |
| 215 | /** |
| 216 | * Called for entries that have been evicted or removed. This method is |
no test coverage detected