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

Method replace

output/java_guava/1.4.17/AtomicLongMap.java:436–443  ·  view source on GitHub ↗

If (key, expectedOldValue) is currently in the map, this method replaces expectedOldValue with newValue and returns true; otherwise, this method returns false. If expectedOldValue is zero, this method will succeed if (key, zero) is currently in the map, or

(K key, long expectedOldValue, long newValue)

Source from the content-addressed store, hash-verified

434 */
435
436 boolean replace(K key, long expectedOldValue, long newValue) {
437 if (expectedOldValue == 0L) {
438 return putIfAbsent(key, newValue) == 0L;
439 } else {
440 AtomicLong atomic = map.get(key);
441 return (atomic == null) ? false : atomic.compareAndSet(expectedOldValue, newValue);
442 }
443 }
444
445 /**
446 * If {@code (key, value)} is currently in the map, this method removes it and returns true;

Callers 4

addAndGetMethod · 0.45
getAndAddMethod · 0.45
putMethod · 0.45
putIfAbsentMethod · 0.45

Calls 3

putIfAbsentMethod · 0.95
getMethod · 0.65
compareAndSetMethod · 0.45

Tested by

no test coverage detected