/** * Removes all mappings from this map whose values are zero. * * <p>This method is not atomic: the map may be visible in intermediate states, where some of the * zero values have been removed and others have not. */ public void removeAllZeros() { map.values().removeIf(x -> x == 0); }
@Override public boolean removeIf(java.util.function.Predicate<? super E> filter) { checkNotNull(filter); return unfiltered.removeIf(element -> predicate.apply(element) && filter.test(element)); }
@Override public boolean removeIf(java.util.function.Predicate<? super T> filter) { checkNotNull(filter); return fromCollection.removeIf(element -> filter.test(function.apply(element))); }
/** * Removes all mappings from this map whose values are zero. * * <p>This method is not atomic: the map may be visible in intermediate states, where some of the * zero values have been removed and others have not. */ public void removeAllZeros() { map.values().removeIf(x -> x == 0); }
@Override public boolean removeIf(Predicate<? super E> filter) { synchronized (mutex) { return delegate().removeIf(filter); } }
void cancelAllJobs() { registry.values().removeIf( future -> { future.cancel( true ); return true; } ); }
@Override public boolean removeIf(Predicate<? super E> filter) { synchronized (mutex) { return delegate().removeIf(filter); } }
public boolean removeIf(Predicate<? super Map.Entry<HeaderName, String>> filter) { return delegate.entries().removeIf(filter); }
@Override public boolean removeIf(java.util.function.Predicate<? super E> filter) { checkNotNull(filter); return unfiltered.removeIf(element -> predicate.apply(element) && filter.test(element)); }
@Override public boolean removeIf(java.util.function.Predicate<? super T> filter) { checkNotNull(filter); return fromCollection.removeIf(element -> filter.test(function.apply(element))); }
/** * Removes, from an iterable, every element that satisfies the provided predicate. * * <p>Removals may or may not happen immediately as each element is tested against the predicate. * The behavior of this method is not specified if {@code predicate} is dependent on {@code * removeFrom}. * * <p><b>Java 8 users:</b> if {@code removeFrom} is a {@link Collection}, use {@code * removeFrom.removeIf(predicate)} instead. * * @param removeFrom the iterable to (potentially) remove elements from * @param predicate a predicate that determines whether an element should be removed * @return {@code true} if any elements were removed from the iterable * @throws UnsupportedOperationException if the iterable does not support {@code remove()}. * @since 2.0 */ @CanIgnoreReturnValue public static <T> boolean removeIf(Iterable<T> removeFrom, Predicate<? super T> predicate) { if (removeFrom instanceof Collection) { return ((Collection<T>) removeFrom).removeIf(predicate); } return Iterators.removeIf(removeFrom.iterator(), predicate); }
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE) public void testRemoveIf_alwaysFalse() { assertFalse("removeIf(x -> false) should return false", collection.removeIf(x -> false)); expectUnchanged(); }
@CollectionFeature.Require(absent = SUPPORTS_REMOVE) @CollectionSize.Require(ZERO) public void testRemoveIf_unsupportedEmptyCollection() { try { assertFalse( "removeIf(Predicate) should return false or throw " + "UnsupportedOperationException", collection.removeIf( x -> { throw new AssertionError("predicate should never be called"); })); } catch (UnsupportedOperationException tolerated) { } expectUnchanged(); }
@CollectionFeature.Require({SUPPORTS_ITERATOR_REMOVE, FAILS_FAST_ON_CONCURRENT_MODIFICATION}) @CollectionSize.Require(SEVERAL) public void testRemoveIfSomeMatchesConcurrentWithIteration() { try { Iterator<E> iterator = collection.iterator(); assertTrue(collection.removeIf(Predicate.isEqual(samples.e0()))); iterator.next(); fail("Expected ConcurrentModificationException"); } catch (ConcurrentModificationException expected) { // success } }
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE) @CollectionSize.Require(absent = ZERO) public void testRemoveIf_allPresent() { assertTrue("removeIf(x -> true) should return true", collection.removeIf(x -> true)); expectContents(); }
@CollectionFeature.Require(absent = SUPPORTS_REMOVE) @CollectionSize.Require(absent = ZERO) public void testRemoveIf_alwaysTrueUnsupported() { try { collection.removeIf(x -> true); fail("removeIf(x -> true) should throw " + "UnsupportedOperationException"); } catch (UnsupportedOperationException expected) { } expectUnchanged(); assertTrue(collection.contains(samples.e0())); } }
protected void processConfigurationClass(ConfigurationClass configClass) throws IOException { if (this.conditionEvaluator.shouldSkip(configClass.getMetadata(), ConfigurationPhase.PARSE_CONFIGURATION)) { return; } ConfigurationClass existingClass = this.configurationClasses.get(configClass); if (existingClass != null) { if (configClass.isImported()) { if (existingClass.isImported()) { existingClass.mergeImportedBy(configClass); } // Otherwise ignore new imported config class; existing non-imported class overrides it. return; } else { // Explicit bean definition found, probably replacing an import. // Let's remove the old one and go with the new one. this.configurationClasses.remove(configClass); this.knownSuperclasses.values().removeIf(configClass::equals); } } // Recursively process the configuration class and its superclass hierarchy. SourceClass sourceClass = asSourceClass(configClass); do { sourceClass = doProcessConfigurationClass(configClass, sourceClass); } while (sourceClass != null); this.configurationClasses.put(configClass, configClass); }
public boolean removeIf(Predicate<? super Map.Entry<HeaderName, String>> filter) { return delegate.entries().removeIf(filter); }
@CacheSpec @CheckNoStats @Test(dataProvider = "caches", expectedExceptions = NullPointerException.class) public void values_removeIf_null(Map<Integer, Integer> map, CacheContext context) { map.values().removeIf(null); }
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE) @CollectionSize.Require(absent = ZERO) public void testRemoveIf_sometimesTrue() { assertTrue( "removeIf(isEqual(present)) should return true", collection.removeIf(Predicate.isEqual(samples.e0()))); expectMissing(samples.e0()); }