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

Method remove

corpus/java/training/guava/cache/LocalCache.java:3123–3168  ·  view source on GitHub ↗
(Object key, int hash)

Source from the content-addressed store, hash-verified

3121 }
3122
3123 @Nullable
3124 V remove(Object key, int hash) {
3125 lock();
3126 try {
3127 long now = map.ticker.read();
3128 preWriteCleanup(now);
3129
3130 int newCount = this.count - 1;
3131 AtomicReferenceArray<ReferenceEntry<K, V>> table = this.table;
3132 int index = hash & (table.length() - 1);
3133 ReferenceEntry<K, V> first = table.get(index);
3134
3135 for (ReferenceEntry<K, V> e = first; e != null; e = e.getNext()) {
3136 K entryKey = e.getKey();
3137 if (e.getHash() == hash
3138 && entryKey != null
3139 && map.keyEquivalence.equivalent(key, entryKey)) {
3140 ValueReference<K, V> valueReference = e.getValueReference();
3141 V entryValue = valueReference.get();
3142
3143 RemovalCause cause;
3144 if (entryValue != null) {
3145 cause = RemovalCause.EXPLICIT;
3146 } else if (valueReference.isActive()) {
3147 cause = RemovalCause.COLLECTED;
3148 } else {
3149 // currently loading
3150 return null;
3151 }
3152
3153 ++modCount;
3154 ReferenceEntry<K, V> newFirst =
3155 removeValueFromChain(first, e, entryKey, hash, entryValue, valueReference, cause);
3156 newCount = this.count - 1;
3157 table.set(index, newFirst);
3158 this.count = newCount; // write-volatile
3159 return entryValue;
3160 }
3161 }
3162
3163 return null;
3164 } finally {
3165 unlock();
3166 postWriteCleanup();
3167 }
3168 }
3169
3170 boolean storeLoadedValue(
3171 K key, int hash, LoadingValueReference<K, V> oldValueReference, V newValue) {

Callers

nothing calls this directly

Calls 15

preWriteCleanupMethod · 0.95
removeValueFromChainMethod · 0.95
postWriteCleanupMethod · 0.95
getMethod · 0.65
getNextMethod · 0.65
getKeyMethod · 0.65
getHashMethod · 0.65
getValueReferenceMethod · 0.65
isActiveMethod · 0.65
setMethod · 0.65
lockMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected