java.util.Collection.removeAll()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中java.util.Collection.removeAll()方法的一些代码示例,展示了Collection.removeAll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Collection.removeAll()方法的具体详情如下:
包路径:java.util.Collection
类名称:Collection
方法名:removeAll

Collection.removeAll介绍

[英]Removes all occurrences in this Collection of each object in the specified Collection (optional). After this method returns none of the elements in the passed Collection can be found in this Collectionanymore.
[中]删除指定集合中每个对象在此集合中的所有引用(可选)。此方法返回后,在此Collectionanymore中找不到传递集合中的任何元素。

代码示例

代码示例来源:origin: neo4j/neo4j

private static Map<Direction, RelationshipType[]> toTypeMap(
    Map<Direction, Collection<RelationshipType>> tempMap )
{
  // Remove OUT/IN where there is a BOTH
  Collection<RelationshipType> both = tempMap.get( Direction.BOTH );
  tempMap.get( Direction.OUTGOING ).removeAll( both );
  tempMap.get( Direction.INCOMING ).removeAll( both );
  // Convert into a final map
  Map<Direction, RelationshipType[]> map = new EnumMap<>( Direction.class );
  for ( Map.Entry<Direction, Collection<RelationshipType>> entry : tempMap.entrySet() )
  {
    if ( !entry.getValue().isEmpty() )
    {
      map.put( entry.getKey(), entry.getValue().toArray( new RelationshipType[entry.getValue().size()] ) );
    }
  }
  return map;
}

代码示例来源:origin: apache/incubator-shardingsphere

/**
 * Get slave data source names.
 *
 * @return available slave data source names
 */
@Override
public Collection<String> getSlaveDataSourceNames() {
  if (disabledDataSourceNames.isEmpty()) {
    return super.getSlaveDataSourceNames();
  }
  Collection<String> result = new LinkedList<>(super.getSlaveDataSourceNames());
  result.removeAll(disabledDataSourceNames);
  return result;
}

代码示例来源:origin: Karumi/Dexter

private void onPermissionsChecked(Collection<String> permissions) {
 if (pendingPermissions.isEmpty()) {
  return;
 }
 synchronized (pendingPermissionsMutex) {
  pendingPermissions.removeAll(permissions);
  if (pendingPermissions.isEmpty()) {
   activity.finish();
   activity = null;
   isRequestingPermission.set(false);
   rationaleAccepted.set(false);
   isShowingNativeDialog.set(false);
   MultiplePermissionsListener currentListener = listener;
   listener = EMPTY_LISTENER;
   currentListener.onPermissionsChecked(multiplePermissionsReport);
  }
 }
}

代码示例来源:origin: apache/ignite

Collection<File> deletedFiles = new HashSet<>(tstampCache.keySet());
deletedFiles.removeAll(foundFiles);
if (!deletedFiles.isEmpty()) {
  List<String> uris = new ArrayList<>();

代码示例来源:origin: apache/hive

private void processAlias(MapWork work, Path path,
  Collection<String> aliasesAffected, Set<String> aliases) {
 // the aliases that are allowed to map to a null scan.
 Collection<String> allowed = aliasesAffected.stream()
   .filter(a -> aliases.contains(a)).collect(Collectors.toList());
 if (!allowed.isEmpty()) {
  PartitionDesc partDesc = work.getPathToPartitionInfo().get(path).clone();
  PartitionDesc newPartition =
    changePartitionToMetadataOnly(partDesc, path);
  // Prefix partition with something to avoid it being a hidden file.
  Path fakePath =
    new Path(NullScanFileSystem.getBase() + newPartition.getTableName()
      + "/part" + encode(newPartition.getPartSpec()));
  StringInternUtils.internUriStringsInPath(fakePath);
  work.addPathToPartitionInfo(fakePath, newPartition);
  work.addPathToAlias(fakePath, new ArrayList<>(allowed));
  aliasesAffected.removeAll(allowed);
  if (aliasesAffected.isEmpty()) {
   work.removePathToAlias(path);
   work.removePathToPartitionInfo(path);
  }
 }
}

代码示例来源:origin: apache/storm

executorsNotScheduled.removeAll(scheduledTasks);
if (!executorsNotScheduled.isEmpty()) {
  LOG.warn("Scheduling {} left over task (most likely sys tasks)", executorsNotScheduled);
  executorsNotScheduled.removeAll(scheduledTasks);
executorsNotScheduled.removeAll(scheduledTasks);
if (executorsNotScheduled.size() > 0) {
  LOG.error("Not all executors successfully scheduled: {}", executorsNotScheduled);

代码示例来源:origin: apache/ignite

/**
 * Perform scan.
 *
 * @param scanCtx Scan context.
 */
private void scan(UriDeploymentScannerContext scanCtx) {
  Collection<String> foundFiles = U.newHashSet(tstampCache.size());
  long start = U.currentTimeMillis();
  processHttp(foundFiles, scanCtx);
  if (scanCtx.getLogger().isDebugEnabled())
    scanCtx.getLogger().debug("HTTP scanner time in ms: " + (U.currentTimeMillis() - start));
  if (!scanCtx.isFirstScan()) {
    Collection<String> deletedFiles = new HashSet<>(tstampCache.keySet());
    deletedFiles.removeAll(foundFiles);
    if (!deletedFiles.isEmpty()) {
      List<String> uris = new ArrayList<>();
      for (String file : deletedFiles)
        uris.add(getFileUri(fileName(file), scanCtx));
      tstampCache.keySet().removeAll(deletedFiles);
      scanCtx.getListener().onDeletedFiles(uris);
    }
  }
}

代码示例来源:origin: google/error-prone

.collect(toImmutableList());
 worklist.addAll(overrides);
 clash.removeAll(overrides);
if (!clash.isEmpty()) {

代码示例来源:origin: stackoverflow.com

if (deque.isEmpty()) { 
  throw new NoSuchElementException("empty stack");
 if (deque.isEmpty()) { 
  throw new NoSuchElementException("empty stack");
{  return deque.isEmpty(); }
{ return deque.removeAll(c); }

代码示例来源:origin: tjake/Solandra

if (!columns.isEmpty())
      columns.removeAll(columnsToRemove);
    if (!columns.isEmpty())

代码示例来源:origin: apache/ignite

assert set.removeAll(c);
assert !set.removeAll(c);
assert set.isEmpty();
assert set.isEmpty();

代码示例来源:origin: apache/ignite

/**
 * This test performs complex set of operations on store from multiple threads.
 *
 * @throws Exception If failed.
 */
private void testPutGetRemove(boolean writeCoalescing) throws Exception {
  initStore(2, writeCoalescing);
  Set<Integer> exp;
  try {
    exp = runPutGetRemoveMultithreaded(10, 10);
  }
  finally {
    shutdownStore();
  }
  Map<Integer, String> map = delegate.getMap();
  Collection<Integer> extra = new HashSet<>(map.keySet());
  extra.removeAll(exp);
  assertTrue("The underlying store contains extra keys: " + extra, extra.isEmpty());
  Collection<Integer> missing = new HashSet<>(exp);
  missing.removeAll(map.keySet());
  assertTrue("Missing keys in the underlying store: " + missing, missing.isEmpty());
  for (Integer key : exp)
    assertEquals("Invalid value for key " + key, "val" + key, map.get(key));
}

代码示例来源:origin: hibernate/hibernate-orm

while ( !toProcessEntities.isEmpty() ) {
  Set<MetaEntity> processedEntities = new HashSet<MetaEntity>();
  int toProcessCountBeforeLoop = toProcessEntities.size();
    processedEntities.add( entity );
  toProcessEntities.removeAll( processedEntities );
  if ( toProcessEntities.size() >= toProcessCountBeforeLoop ) {
    context.logMessage(

代码示例来源:origin: apache/kylin

if (!unmatchedAggregations.isEmpty()) {
  removeUnmatchedGroupingAgg(unmatchedAggregations);
  tryDimensionAsMeasures(unmatchedAggregations, result,
  if (!unmatchedAggregations.isEmpty()) {
    Iterator<FunctionDesc> itr = unmatchedAggregations.iterator();
    while (itr.hasNext()) {
  if (!unmatchedDimensions.isEmpty()) {
    unmatchedDimensions.removeAll(dimCols);

代码示例来源:origin: apache/ignite

Collection<Integer> cp = new HashSet<>(original);
cp.removeAll(linkedMap.keySet());
assertTrue("Keys disappeared from map: " + cp, cp.isEmpty());

代码示例来源:origin: apache/ignite

extra.removeAll(exp);
assertTrue("The underlying store contains extra keys: " + extra, extra.isEmpty());
missing.removeAll(map.keySet());
assertTrue("Missing keys in the underlying store: " + missing, missing.isEmpty());

代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin

private void doTestVariantsInner(@NotNull CompletionType type, int count, CheckType checkType, String... variants) {
 myFixture.complete(type, count);
 List<String> stringList = myFixture.getLookupElementStrings();
 assertNotNull("\nPossibly the single variant has been completed.\nFile after:\n" + myFixture.getFile().getText(), stringList);
 Collection<String> varList = ContainerUtil.newArrayList(variants);
 if (checkType == CheckType.ORDERED_EQUALS) {
  UsefulTestCase.assertOrderedEquals(stringList, variants);
 }
 else if (checkType == CheckType.EQUALS) {
  UsefulTestCase.assertSameElements(stringList, variants);
 }
 else if (checkType == CheckType.INCLUDES) {
  varList.removeAll(stringList);
  assertTrue("Missing variants: " + varList, varList.isEmpty());
 }
 else if (checkType == CheckType.EXCLUDES) {
  varList.retainAll(stringList);
  assertTrue("Unexpected variants: " + varList, varList.isEmpty());
 }
}

代码示例来源:origin: apache/ignite

expOnly.removeAll(cacheKeys);
cacheOnly.removeAll(expVals.keySet());
if (!expOnly.isEmpty())
  log.error("Cache does not contain expected keys: " + expOnly);
if (!cacheOnly.isEmpty())
  log.error("Cache does contain unexpected keys: " + cacheOnly);
expOnly.removeAll(dhtCacheKeys);
cacheOnly.removeAll(expVals.keySet());
if (!expOnly.isEmpty())
  log.error("DHT cache does not contain expected keys: " + expOnly);

代码示例来源:origin: apache/ignite

original.removeAll(keys);
assertTrue("Keys must be in map: " + original, original.isEmpty());

代码示例来源:origin: apache/ignite

extra.removeAll(exp);
assertTrue("The underlying store contains extra keys: " + extra, extra.isEmpty());
missing.removeAll(map.keySet());
assertTrue("Missing keys in the underlying store: " + missing, missing.isEmpty());

相关文章