Tabnine Logo
List.retainAll
Code IndexAdd Tabnine to your IDE (free)

How to use
retainAll
method
in
java.util.List

Best Java code snippets using java.util.List.retainAll (Showing top 20 results out of 6,687)

Refine searchRefine arrow

  • List.size
  • List.add
origin: ch.qos.logback/logback-classic

private void resetListenersExceptResetResistant() {
  List<LoggerContextListener> toRetain = new ArrayList<LoggerContextListener>();
  for (LoggerContextListener lcl : loggerContextListenerList) {
    if (lcl.isResetResistant()) {
      toRetain.add(lcl);
    }
  }
  loggerContextListenerList.retainAll(toRetain);
}
origin: commons-collections/commons-collections

public boolean retainAll(Collection o) {
  if (fast) {
    synchronized (FastArrayList.this) {
      ArrayList temp = (ArrayList) list.clone();
      List sub = get(temp);
      boolean r = sub.retainAll(o);
      if (r) last = first + sub.size();
      list = temp;
      expected = temp;
      return r;
    }
  } else {
    synchronized (list) {
      return get(expected).retainAll(o);
    }
  }
}
origin: apache/incubator-pinot

   serverToSegmentsMap.put(serverName, segmentsForServer);
  segmentsForServer.add(entry.getKey());
int numServers = servers.size();
 String randomServer = serversForSegment.get(_random.nextInt(serversForSegment.size()));
 serversInRoutingTable.add(randomServer);
 segmentsNotHandledByServers.removeAll(serverToSegmentsMap.get(randomServer));
 serversForSegment.retainAll(serversInRoutingTable);
  routingTable.put(serverWithLeastSegmentsAssigned, segmentsAssignedToServer);
 segmentsAssignedToServer.add(segmentName);
origin: ReactiveX/RxJava

assertEquals(0, list.size());
assertFalse(list.contains(1));
assertFalse(list.remove((Integer)1));
assertTrue(list.add(1));
assertTrue(list.addAll(Arrays.asList(3, 4, 7)));
list.add(1, 2);
assertTrue(list.addAll(4, Arrays.asList(5, 6)));
assertEquals(7, list.size());
assertFalse(list.retainAll(Arrays.asList(1, 2, 3, 4, 5, 6, 7)));
assertEquals(7, list.size());
assertFalse(list.equals(list3));
list3.add(7);
assertTrue(list3.equals(list));
assertTrue(list.equals(list3));
origin: commons-collections/commons-collections

protected void verifyUnmodifiable(List list) {
  try {
    list.add(0, new Integer(0));
    fail("Expecting UnsupportedOperationException.");
  } catch (UnsupportedOperationException e) {
    list.add(new Integer(0));
     fail("Expecting UnsupportedOperationException.");
  } catch (UnsupportedOperationException e) {
    list.retainAll(array);
     fail("Expecting UnsupportedOperationException.");
  } catch (UnsupportedOperationException e) {
origin: apache/kylin

remaining.retainAll(selected);
Preconditions.checkArgument(remaining.isEmpty(),
    "There should be no intersection between excluded list and selected list.");
  logger.trace("Excluded cuboidId size: {}", excluded.size());
  logger.trace("Excluded cuboidId detail:");
  for (Long cuboid : excluded) {
origin: rapidoid/rapidoid

private String pickMainClass(List<String> mainClasses, MavenProject project) {
  // the.group.id.Main
  String byGroupId = project.getGroupId() + ".Main";
  if (mainClasses.contains(byGroupId)) return byGroupId;
  List<String> namedMain = U.list();
  List<String> withGroupIdPkg = U.list();
  for (String name : mainClasses) {
    if (name.equals("Main")) return "Main";
    if (name.endsWith(".Main")) {
      namedMain.add(name);
    }
    if (name.startsWith(project.getGroupId() + ".")) {
      withGroupIdPkg.add(name);
    }
  }
  // the.group.id.foo.bar.Main
  getLog().info("Candidates by group ID: " + withGroupIdPkg);
  if (withGroupIdPkg.size() == 1) return U.single(withGroupIdPkg);
  // foo.bar.Main
  getLog().info("Candidates named Main: " + namedMain);
  if (namedMain.size() == 1) return U.single(namedMain);
  namedMain.retainAll(withGroupIdPkg);
  getLog().info("Candidates by group ID - named Main: " + namedMain);
  if (namedMain.size() == 1) return U.single(namedMain);
  // the.group.id.foo.bar.Main (the shortest name)
  withGroupIdPkg.sort((s1, s2) -> s1.length() - s2.length());
  getLog().info("Candidates by group ID - picking one with the shortest name: " + withGroupIdPkg);
  return U.first(withGroupIdPkg);
}
origin: stackoverflow.com

 List<Integer> l1 = new ArrayList<Integer>();

l1.add(1);
l1.add(2);
l1.add(3);

List<Integer> l2= new ArrayList<Integer>();
l2.add(4);
l2.add(2);
l2.add(3);

System.out.println("l1 == "+l1);
System.out.println("l2 == "+l2);

List<Integer> l3 = new ArrayList<Integer>(l2);
l3.retainAll(l1);

  System.out.println("l3 == "+l3);
  System.out.println("l2 == "+l2);
origin: wildfly/wildfly

public boolean retainAll(Collection o) {
  if (fast) {
    synchronized (FastArrayList.this) {
      ArrayList temp = (ArrayList) list.clone();
      List sub = get(temp);
      boolean r = sub.retainAll(o);
      if (r) last = first + sub.size();
      list = temp;
      expected = temp;
      return r;
    }
  } else {
    synchronized (list) {
      return get(expected).retainAll(o);
    }
  }
}
origin: apache/cloudstack

for (StoragePoolVO storagePool : storagePools) {
  if (HypervisorType.Any.equals(storagePool.getHypervisor())) {
    anyHypervisorStoragePools.add(storagePool);
storagePools.retainAll(storagePoolsByHypervisor);
storagePools.addAll(anyHypervisorStoragePools);
  if (suitablePools.size() == returnUpTo) {
    break;
    suitablePools.add(storagePool);
  } else {
    if (canAddStoragePoolToAvoidSet(storage)) {
origin: camunda/camunda-bpm-platform

 cachedCandidateGroups.add(candidateGroup);
cachedCandidateGroups.retainAll(Arrays.asList(candidateGroup));
origin: spinnaker/kayenta

public static boolean haveCommonElements(List<String> listOne, List<String> listTwo) {
 List<String> tempList = new ArrayList<>();
 tempList.addAll(listOne);
 tempList.retainAll(listTwo);
 return tempList.size() > 0;
}
origin: elastic/elasticsearch-hadoop

  log.debug(String.format("Found client nodes %s", clientNodes));
List<String> toRetain = new ArrayList<String>(clientNodes.size());
for (NodeInfo node : clientNodes) {
  toRetain.add(node.getPublishAddress());
ddNodes.retainAll(toRetain);
if (log.isDebugEnabled()) {
  log.debug(String.format("Filtered discovered only nodes %s to client-only %s", SettingsUtils.discoveredOrDeclaredNodes(settings), ddNodes));
origin: org.codehaus.groovy/groovy

public boolean retainAll(Collection c) {
  if (c == null) {
    return false;
  }
  List values = new ArrayList();
  // GROOVY-7783 use Set for O(1) performance for contains
  if (!(c instanceof Set)) {
    c = new HashSet<Object>(c);
  }
  for (Object element : delegate) {
    if (!c.contains(element)) {
      values.add(element);
    }
  }
  int oldSize = size();
  boolean success = delegate.retainAll(c);
  if (success && !values.isEmpty()) {
    fireMultiElementRemovedEvent(values);
    fireSizeChangedEvent(oldSize, size());
  }
  return success;
}
origin: jMonkeyEngine/jmonkeyengine

public boolean retainAll(Collection<?> c) {
  boolean result = getBuffer().retainAll(c);
  size = getBuffer().size();
  return result;
}
origin: camunda/camunda-bpm-platform

 cachedCandidateGroups.add(candidateGroup);
cachedCandidateGroups.retainAll(Arrays.asList(candidateGroup));
origin: com.netflix.kayenta/kayenta-core

public static boolean haveCommonElements(List<String> listOne, List<String> listTwo) {
 List<String> tempList = new ArrayList<>();
 tempList.addAll(listOne);
 tempList.retainAll(listTwo);
 return tempList.size() > 0;
}
origin: elastic/elasticsearch-hadoop

  log.debug(String.format("Found data nodes %s", dataNodes));
List<String> toRetain = new ArrayList<String>(dataNodes.size());
for (NodeInfo node : dataNodes) {
  toRetain.add(node.getPublishAddress());
ddNodes.retainAll(toRetain);
if (log.isDebugEnabled()) {
  log.debug(String.format("Filtered discovered only nodes %s to data-only %s", SettingsUtils.discoveredOrDeclaredNodes(settings), ddNodes));
origin: wildfly/wildfly

members.retainAll(gms.view().getMembers());
  members.add(gms.local_addr);
origin: robolectric/robolectric

@Override
public int restoreSome(
  long token, IRestoreObserver observer, IBackupManagerMonitor monitor, String[] packages)
  throws RemoteException {
 List<String> restorePackages = new ArrayList<>(serviceState.restoreData.get(token));
 if (packages != null) {
  restorePackages.retainAll(Arrays.asList(packages));
 }
 post(() -> observer.restoreStarting(restorePackages.size()));
 for (int i = 0; i < restorePackages.size(); i++) {
  final int index = i; // final copy of i
  post(() -> observer.onUpdate(index, restorePackages.get(index)));
  serviceState.restoredPackages.put(restorePackages.get(index), token);
 }
 post(() -> observer.restoreFinished(BackupManager.SUCCESS));
 serviceState.lastRestoreToken = token;
 return BackupManager.SUCCESS;
}
java.utilListretainAll

Javadoc

Removes all objects from this List that are not contained in the specified collection.

Popular methods of List

  • add
  • size
    Returns the number of elements in this List.
  • get
    Returns the element at the specified location in this List.
  • isEmpty
    Returns whether this List contains no elements.
  • addAll
  • toArray
    Returns an array containing all elements contained in this List. If the specified array is large eno
  • contains
    Tests whether this List contains the specified object.
  • remove
    Removes the first occurrence of the specified object from this List.
  • iterator
    Returns an iterator on the elements of this List. The elements are iterated in the same order as the
  • clear
  • stream
  • forEach
  • stream,
  • forEach,
  • set,
  • subList,
  • indexOf,
  • equals,
  • hashCode,
  • removeAll,
  • listIterator,
  • sort

Popular in Java

  • Making http requests using okhttp
  • scheduleAtFixedRate (Timer)
  • startActivity (Activity)
  • getApplicationContext (Context)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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