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

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

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

Collection.containsAll介绍

[英]Tests whether this Collection contains all objects contained in the specified Collection. If an element elem is contained several times in the specified Collection, the method returns true even if elem is contained only once in this Collection.
[中]测试此集合是否包含指定集合中包含的所有对象。如果指定集合中多次包含元素elem,则即使该集合中只包含一次elem,该方法也会返回true。

代码示例

代码示例来源:origin: skylot/jadx

private static boolean sameElements(Collection<BlockNode> c1, Collection<BlockNode> c2) {
  return c1.size() == c2.size() && c1.containsAll(c2);
}

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

private static boolean isCollectionEqual(Collection<String> c1, Collection<String> c2) {
 if (c1 == null) {
  return c2 == null;
 }
 if (c2 == null) {
  return false;
 }
 return c1.size() == c2.size() && c1.containsAll(c2);
}

代码示例来源:origin: commons-collections/commons-collections

return true;
if (set1 == null || set2 == null || set1.size() != set2.size()) {
  return false;
return set1.containsAll(set2);

代码示例来源:origin: org.apache.lucene/lucene-core

/** Create a new {@link ConjunctionScorer}, note that {@code scorers} must be a subset of {@code required}. */
ConjunctionScorer(Weight weight, Collection<Scorer> required, Collection<Scorer> scorers) {
 super(weight);
 assert required.containsAll(scorers);
 this.disi = ConjunctionDISI.intersectScorers(required);
 this.scorers = scorers.toArray(new Scorer[scorers.size()]);
 this.required = required;
}

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

return true;
if (set1 == null || set2 == null || set1.size() != set2.size()) {
  return false;
return set1.containsAll(set2);

代码示例来源:origin: org.apache.commons/commons-collections4

return true;
if (set1 == null || set2 == null || set1.size() != set2.size()) {
  return false;
return set1.containsAll(set2);

代码示例来源:origin: google/guava

@MapFeature.Require({SUPPORTS_PUT, SUPPORTS_REMOVE})
public void testReplaceValuesWithDuplicates() {
 int size = multimap().size();
 List<V> oldValues = new ArrayList<>(multimap().get(k0()));
 List<V> values = Arrays.asList(v0(), v3(), v0());
 assertEquals(oldValues, new ArrayList<V>(multimap().replaceValues(k0(), values)));
 assertEquals(size - oldValues.size() + multimap().get(k0()).size(), multimap().size());
 assertTrue(multimap().get(k0()).containsAll(values));
}

代码示例来源:origin: google/guava

/** Helper assertion comparing two maps */
private void assertMapsEqual(Map<?, ?> expected, Map<?, ?> map) {
 assertEquals(expected, map);
 assertEquals(expected.hashCode(), map.hashCode());
 assertEquals(expected.entrySet(), map.entrySet());
 // Assert that expectedValues > mapValues and that
 // mapValues > expectedValues; i.e. that expectedValues == mapValues.
 Collection<?> expectedValues = expected.values();
 Collection<?> mapValues = map.values();
 assertEquals(expectedValues.size(), mapValues.size());
 assertTrue(expectedValues.containsAll(mapValues));
 assertTrue(mapValues.containsAll(expectedValues));
}

代码示例来源:origin: google/guava

/** Helper assertion comparing two maps */
private void assertMapsEqual(Map<?, ?> expected, Map<?, ?> map) {
 assertEquals(expected, map);
 assertEquals(expected.hashCode(), map.hashCode());
 assertEquals(expected.entrySet(), map.entrySet());
 // Assert that expectedValues > mapValues and that
 // mapValues > expectedValues; i.e. that expectedValues == mapValues.
 Collection<?> expectedValues = expected.values();
 Collection<?> mapValues = map.values();
 assertEquals(expectedValues.size(), mapValues.size());
 assertTrue(expectedValues.containsAll(mapValues));
 assertTrue(mapValues.containsAll(expectedValues));
}

代码示例来源:origin: google/guava

assertTrue(map.containsValue(value));
 assertTrue(valueCollection.contains(value));
 assertTrue(valueCollection.containsAll(Collections.singleton(value)));
 assertTrue(entrySet.contains(mapEntry(key, value)));
 assertTrue(allowsNullKeys || (key != null));
assertEquals(map.size(), valueCollection.size());
assertEquals(valueCollection.size() == 0, valueCollection.isEmpty());
assertEquals(!valueCollection.isEmpty(), valueCollection.iterator().hasNext());
for (V value : valueCollection) {

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

/**
 *
 */
private Collection<IgniteInternalCache> manageStatisticsCaches(Collection<String> caches)
  throws IgniteCheckedException {
  assert caches != null;
  Collection<IgniteInternalCache> res = new ArrayList<>(caches.size());
  if (!cacheNames().containsAll(caches))
    throw new IgniteCheckedException("One or more cache descriptors not found [caches=" + caches + ']');
  for (String cacheName : caches) {
    IgniteInternalCache cache = cache(cacheName);
    if (cache == null)
      throw new IgniteCheckedException("Cache not found [cacheName=" + cacheName + ']');
    res.add(cache);
  }
  return res;
}

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

int size = groupsD.size();
if (!groupsD.containsAll(cuboid.getColumns().subList(0, size))) {
  storageLimitLevel = StorageLimitLevel.LIMIT_ON_RETURN_SIZE;
  logger.debug(
if (!groups.containsAll(derivedPostAggregation)) {
  storageLimitLevel = StorageLimitLevel.NO_LIMIT;
  logger.debug("storageLimitLevel set to NO_LIMIT because derived column require post aggregation: {0}",

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

private void verifyCollectionsEqual(Collection<HStoreFile> sfs, Collection<HStoreFile> scr) {
 // Dumb.
 assertEquals(sfs.size(), scr.size());
 assertTrue(scr.containsAll(sfs));
}

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

private static void compareDatabaseVersionChunks(Collection<ChunkEntry> writtenChunks, Collection<ChunkEntry> readChunks) {
  assertEquals("Different amount of Chunk objects.", writtenChunks.size(), readChunks.size());
  assertTrue("Chunk objects in written/read database version different.", writtenChunks.containsAll(readChunks));
  //assertCollectionEquals("Chunk objects in written/read database version different.", writtenChunks, readChunks);
}

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

private static void compareDatabaseVersionFileContents(Collection<FileContent> writtenFileContents, Collection<FileContent> readFileContents) {
  assertEquals("Different amount of FileContent objects.", writtenFileContents.size(), readFileContents.size());
  assertTrue("FileContent objects in written/read database version different.", writtenFileContents.containsAll(readFileContents));
  //assertCollectionEquals("FileContent objects in written/read database version different.", writtenFileContents, readFileContents);
}

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

private static void compareDatabaseVersionMultiChunks(Collection<MultiChunkEntry> writtenMultiChunks, Collection<MultiChunkEntry> readMultiChunks) {
  assertEquals("Different amount of MultiChunk objects.", writtenMultiChunks.size(), readMultiChunks.size());
  assertTrue("MultiChunk objects in written/read database version different.", writtenMultiChunks.containsAll(readMultiChunks));
  //assertCollectionEquals("MultiChunk objects in written/read database version different.", writtenMultiChunks, readMultiChunks);
}

代码示例来源:origin: spring-projects/spring-batch

private <T, S extends T> void assertSameCollections(Collection<S> expected, Collection<T> actual) {
  assertEquals(expected.size(), actual.size());
  assertTrue(expected.containsAll(actual));
}

代码示例来源:origin: commons-collections/commons-collections

public void testAddAllToCollection() {
  setUpTest();
  one.add("1");
  two.add("2");
  c.addComposited(one, two);
  Collection toCollection = new HashSet();
  toCollection.addAll(c);
  assertTrue(toCollection.containsAll(c));
  assertEquals(c.size(), toCollection.size());
}

代码示例来源:origin: Alluxio/alluxio

private void assertExpired(List<TtlBucket> expiredBuckets, int bucketIndex,
  Inode... inodes) {
 TtlBucket bucket = expiredBuckets.get(bucketIndex);
 Assert.assertEquals(inodes.length, bucket.getInodes().size());
 Assert.assertTrue(bucket.getInodes().containsAll(Lists.newArrayList(inodes)));
}

代码示例来源:origin: commons-collections/commons-collections

public void testToCollection() {
  setUpTest();
  one.add("1");
  two.add("2");
  c.addComposited(one, two);
  Collection foo = c.toCollection();
  assertTrue(foo.containsAll(c));
  assertEquals(c.size(), foo.size());
  one.add("3");
  assertTrue(!foo.containsAll(c));
}

相关文章