(@Nullable Object value)
| 4179 | } |
| 4180 | |
| 4181 | @Override |
| 4182 | public boolean containsValue(@Nullable Object value) { |
| 4183 | // does not impact recency ordering |
| 4184 | if (value == null) { |
| 4185 | return false; |
| 4186 | } |
| 4187 | |
| 4188 | // This implementation is patterned after ConcurrentHashMap, but without the locking. The only |
| 4189 | // way for it to return a false negative would be for the target value to jump around in the map |
| 4190 | // such that none of the subsequent iterations observed it, despite the fact that at every point |
| 4191 | // in time it was present somewhere int the map. This becomes increasingly unlikely as |
| 4192 | // CONTAINS_VALUE_RETRIES increases, though without locking it is theoretically possible. |
| 4193 | |
| 4194 | long now = ticker.read(); |
| 4195 | final Segment<K, V>[] segments = this.segments; |
| 4196 | long last = -1L; |
| 4197 | for (int i = 0; i < CONTAINS_VALUE_RETRIES; i++) { |
| 4198 | long sum = 0L; |
| 4199 | for (Segment<K, V> segment : segments) { |
| 4200 | // ensure visibility of most recent completed write |
| 4201 | int unused = segment.count; // read-volatile |
| 4202 | AtomicReferenceArray<ReferenceEntry<K, V>> table = segment.table; |
| 4203 | for (int j = 0; j < table.length(); j++) { |
| 4204 | for (ReferenceEntry<K, V> e = table.get(j); e != null; e = e.getNext()) { |
| 4205 | V v = segment.getLiveValue(e, now); |
| 4206 | if (v != null && valueEquivalence.equivalent(value, v)) { |
| 4207 | return true; |
| 4208 | } |
| 4209 | } |
| 4210 | } |
| 4211 | sum += segment.modCount; |
| 4212 | } |
| 4213 | if (sum == last) { |
| 4214 | break; |
| 4215 | } |
| 4216 | last = sum; |
| 4217 | } |
| 4218 | return false; |
| 4219 | } |
| 4220 | |
| 4221 | @Override |
| 4222 | public V put(K key, V value) { |
nothing calls this directly
no test coverage detected