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