MCPcopy
hub / github.com/google/guava / remove

Method remove

guava/src/com/google/common/cache/LocalCache.java:3053–3097  ·  view source on GitHub ↗
(Object key, int hash)

Source from the content-addressed store, hash-verified

3051 }
3052
3053 @Nullable V remove(Object key, int hash) {
3054 lock();
3055 try {
3056 long now = map.ticker.read();
3057 preWriteCleanup(now);
3058
3059 int newCount = this.count - 1;
3060 AtomicReferenceArray<ReferenceEntry<K, V>> table = this.table;
3061 int index = hash & (table.length() - 1);
3062 ReferenceEntry<K, V> first = table.get(index);
3063
3064 for (ReferenceEntry<K, V> e = first; e != null; e = e.getNext()) {
3065 K entryKey = e.getKey();
3066 if (e.getHash() == hash
3067 && entryKey != null
3068 && map.keyEquivalence.equivalent(key, entryKey)) {
3069 ValueReference<K, V> valueReference = e.getValueReference();
3070 V entryValue = valueReference.get();
3071
3072 RemovalCause cause;
3073 if (entryValue != null) {
3074 cause = RemovalCause.EXPLICIT;
3075 } else if (valueReference.isActive()) {
3076 cause = RemovalCause.COLLECTED;
3077 } else {
3078 // currently loading
3079 return null;
3080 }
3081
3082 ++modCount;
3083 ReferenceEntry<K, V> newFirst =
3084 removeValueFromChain(first, e, entryKey, hash, entryValue, valueReference, cause);
3085 newCount = this.count - 1;
3086 table.set(index, newFirst);
3087 this.count = newCount; // write-volatile
3088 return entryValue;
3089 }
3090 }
3091
3092 return null;
3093 } finally {
3094 unlock();
3095 postWriteCleanup();
3096 }
3097 }
3098
3099 boolean remove(Object key, int hash, Object value) {
3100 lock();

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