@Override public synchronized void replaceAll( BiFunction<? super Object, ? super Object, ? extends Object> function ) { storageMap.replaceAll( function ); }
@Override public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) { delegate().replaceAll(function); } @Override public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
@Override public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) { map.replaceAll((k, v) -> { checkType(k); checkType(v); V output = function.apply(k, v); if (output != null) { checkType(output); } return output; }); }
/** * replaceAll replaces all matching values. */ public void testReplaceAll() { ConcurrentMap<Integer, String> map = map5(); map.replaceAll((x, y) -> { return x > 3 ? "Z" : y; }); assertEquals("A", map.get(one)); assertEquals("B", map.get(two)); assertEquals("C", map.get(three)); assertEquals("Z", map.get(four)); assertEquals("Z", map.get(five)); }
@Override public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) { map.replaceAll((k, v) -> { checkType(k); checkType(v); V output = function.apply(k, v); if (output != null) { checkType(output); } return output; }); }
@Override public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) { delegate().replaceAll(function); } @Override public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
/** * Iterates over all entries in the cache and replaces their value with the one provided by the given function. * If the function throws an exception, the iteration is stopped and the exception is propagated. If any value * is under computation in other threads, then the iteration will block on that entry until its computation is * completed. * * @param remapping the function computing new values from the old ones. * * @since 1.0 */ @Override public void replaceAll(final BiFunction<? super K, ? super V, ? extends V> remapping) { final ReplaceAdapter adapter = new ReplaceAdapter(remapping); map.replaceAll(adapter); Deferred.notifyChanges(this, adapter.changes); }
@Test(expected = CPUReactiveAuditException.class) public void replaceAll() { TestTools.strict.commit(); ConcurrentMap<Object,Object> q = new ConcurrentHashMap<>(); q.replaceAll(null); } @Test(expected = CPUReactiveAuditException.class)