MCPcopy Create free account
hub / github.com/antlr/codebuff / remove

Method remove

output/java_guava/1.4.17/AtomicLongMap.java:256–272  ·  view source on GitHub ↗

Removes and returns the value associated with key. If key is not in the map, this method has no effect and returns zero.

(K key)

Source from the content-addressed store, hash-verified

254 */
255
256 @CanIgnoreReturnValue
257 public long remove(K key) {
258 AtomicLong atomic = map.get(key);
259 if (atomic == null) {
260 return 0L;
261 }
262
263 while (true) {
264 long oldValue = atomic.get();
265 if (oldValue == 0L || atomic.compareAndSet(oldValue, 0L)) {
266 // only remove after setting to zero, to avoid concurrent updates
267 map.remove(key, atomic);
268 // succeed even if the remove fails, since the value was already adjusted
269 return oldValue;
270 }
271 }
272 }
273
274 /**
275 * Removes all mappings from this map whose values are zero.

Callers

nothing calls this directly

Calls 3

getMethod · 0.65
removeMethod · 0.65
compareAndSetMethod · 0.45

Tested by

no test coverage detected