/** * Clears all cache entries whose value matches the given predicate. */ public void removeValueMatching(MatchPredicate<V> predicate) { synchronized (cache) { Iterator<V> it = cache.values().iterator(); while (it.hasNext()) { V value = it.next(); if (predicate.matches(value)) { it.remove(); } } } }
/** * Clears all cache entries whose value matches the given predicate. */ public void removeValueMatching(MatchPredicate<V> predicate) { synchronized (cache) { Iterator<V> it = cache.values().iterator(); while (it.hasNext()) { V value = it.next(); if (predicate.matches(value)) { it.remove(); } } } }
/** * Clears all cache entries whose value matches the given predicate. */ public void removeValueMatching(MatchPredicate<V> predicate) { synchronized (cache) { Iterator<V> it = cache.values().iterator(); while (it.hasNext()) { V value = it.next(); if (predicate.matches(value)) { it.remove(); } } } }
/** * Clears all cache entries whose key matches the given predicate. */ public void removeKeysMatching(MatchPredicate<K> predicate) { synchronized (cache) { Iterator<K> it = cache.keySet().iterator(); while (it.hasNext()) { K key = it.next(); if (predicate.matches(key)) { it.remove(); } } } }
/** * Clears all cache entries whose key matches the given predicate. */ public void removeKeysMatching(MatchPredicate<K> predicate) { synchronized (cache) { Iterator<K> it = cache.keySet().iterator(); while (it.hasNext()) { K key = it.next(); if (predicate.matches(key)) { it.remove(); } } } }
/** * Clears all cache entries whose key matches the given predicate. */ public void removeKeysMatching(MatchPredicate<K> predicate) { synchronized (cache) { Iterator<K> it = cache.keySet().iterator(); while (it.hasNext()) { K key = it.next(); if (predicate.matches(key)) { it.remove(); } } } }