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

Method containsValue

output/java_guava/1.4.13/LocalCache.java:4163–4201  ·  view source on GitHub ↗
(@Nullable Object value)

Source from the content-addressed store, hash-verified

4161 }
4162
4163 @Override
4164 public boolean containsValue(@Nullable Object value) {
4165 // does not impact recency ordering
4166 if (value == null) {
4167 return false;
4168 }
4169
4170 // This implementation is patterned after ConcurrentHashMap, but without the locking. The only
4171 // way for it to return a false negative would be for the target value to jump around in the map
4172 // such that none of the subsequent iterations observed it, despite the fact that at every point
4173 // in time it was present somewhere int the map. This becomes increasingly unlikely as
4174 // CONTAINS_VALUE_RETRIES increases, though without locking it is theoretically possible.
4175
4176 long now = ticker.read();
4177 final Segment<K, V>[] segments = this.segments;
4178 long last = -1L;
4179 for (int i = 0; i < CONTAINS_VALUE_RETRIES; i++) {
4180 long sum = 0L;
4181 for (Segment<K, V> segment : segments) {
4182 // ensure visibility of most recent completed write
4183 int unused = segment.count; // read-volatile
4184 AtomicReferenceArray<ReferenceEntry<K, V>> table = segment.table;
4185 for (int j = 0; j < table.length(); j++) {
4186 for (ReferenceEntry<K, V> e = table.get(j); e != null; e = e.getNext()) {
4187 V v = segment.getLiveValue(e, now);
4188 if (v != null && valueEquivalence.equivalent(value, v)) {
4189 return true;
4190 }
4191 }
4192 }
4193 sum += segment.modCount;
4194 }
4195 if (sum == last) {
4196 break;
4197 }
4198 last = sum;
4199 }
4200 return false;
4201 }
4202
4203 @Override
4204 public V put(K key, V value) {

Callers

nothing calls this directly

Calls 6

getMethod · 0.65
getNextMethod · 0.65
readMethod · 0.45
lengthMethod · 0.45
getLiveValueMethod · 0.45
equivalentMethod · 0.45

Tested by

no test coverage detected