congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Collection.removeIf
Code IndexAdd Tabnine to your IDE (free)

How to use
removeIf
method
in
java.util.Collection

Best Java code snippets using java.util.Collection.removeIf (Showing top 20 results out of 1,476)

origin: google/guava

/**
 * 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);
}
origin: google/guava

@Override
public boolean removeIf(java.util.function.Predicate<? super E> filter) {
 checkNotNull(filter);
 return unfiltered.removeIf(element -> predicate.apply(element) && filter.test(element));
}
origin: google/guava

@Override
public boolean removeIf(java.util.function.Predicate<? super T> filter) {
 checkNotNull(filter);
 return fromCollection.removeIf(element -> filter.test(function.apply(element)));
}
origin: prestodb/presto

/**
 * 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);
}
origin: google/guava

@Override
public boolean removeIf(Predicate<? super E> filter) {
 synchronized (mutex) {
  return delegate().removeIf(filter);
 }
}
origin: neo4j/neo4j

void cancelAllJobs()
{
  registry.values().removeIf( future ->
  {
    future.cancel( true );
    return true;
  } );
}
origin: prestodb/presto

@Override
public boolean removeIf(Predicate<? super E> filter) {
 synchronized (mutex) {
  return delegate().removeIf(filter);
 }
}
origin: Netflix/zuul

public boolean removeIf(Predicate<? super Map.Entry<HeaderName, String>> filter) {
  return delegate.entries().removeIf(filter);
}
origin: prestodb/presto

@Override
public boolean removeIf(java.util.function.Predicate<? super E> filter) {
 checkNotNull(filter);
 return unfiltered.removeIf(element -> predicate.apply(element) && filter.test(element));
}
origin: prestodb/presto

@Override
public boolean removeIf(java.util.function.Predicate<? super T> filter) {
 checkNotNull(filter);
 return fromCollection.removeIf(element -> filter.test(function.apply(element)));
}
origin: google/guava

/**
 * 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);
}
origin: google/guava

@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
public void testRemoveIf_alwaysFalse() {
 assertFalse("removeIf(x -> false) should return false", collection.removeIf(x -> false));
 expectUnchanged();
}
origin: google/guava

@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();
}
origin: google/guava

@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
 }
}
origin: google/guava

@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();
}
origin: google/guava

 @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()));
 }
}
origin: spring-projects/spring-framework

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);
}
origin: Netflix/zuul

public boolean removeIf(Predicate<? super Map.Entry<HeaderName, String>> filter) {
  return delegate.entries().removeIf(filter);
}
origin: ben-manes/caffeine

@CacheSpec
@CheckNoStats
@Test(dataProvider = "caches", expectedExceptions = NullPointerException.class)
public void values_removeIf_null(Map<Integer, Integer> map, CacheContext context) {
 map.values().removeIf(null);
}
origin: google/guava

@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());
}
java.utilCollectionremoveIf

Popular methods of Collection

  • size
    Returns the number of elements in this collection. If this collection contains more than Integer.MAX
  • iterator
    Returns an iterator over the elements in this collection. There are no guarantees concerning the ord
  • add
  • isEmpty
    Returns true if this collection contains no elements.
  • contains
  • toArray
  • stream
  • addAll
  • forEach
  • remove
  • clear
  • removeAll
  • clear,
  • removeAll,
  • containsAll,
  • equals,
  • hashCode,
  • retainAll,
  • parallelStream,
  • spliterator,
  • <init>

Popular in Java

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • putExtra (Intent)
  • setContentView (Activity)
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now