本文整理了Java中java.util.Set.containsAll()
方法的一些代码示例,展示了Set.containsAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Set.containsAll()
方法的具体详情如下:
包路径:java.util.Set
类名称:Set
方法名:containsAll
[英]Searches this set for all objects in the specified collection.
[中]在该集合中搜索指定集合中的所有对象。
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public boolean containsAll(Collection<?> c) {
return map.keySet().containsAll(c);
}
代码示例来源:origin: google/guava
/** An implementation for {@link Set#equals(Object)}. */
static boolean equalsImpl(Set<?> s, @Nullable Object object) {
if (s == object) {
return true;
}
if (object instanceof Set) {
Set<?> o = (Set<?>) object;
try {
return s.size() == o.size() && s.containsAll(o);
} catch (NullPointerException | ClassCastException ignored) {
return false;
}
}
return false;
}
代码示例来源:origin: prestodb/presto
public void noMoreSplits(PlanNodeId planNodeId)
{
if (noMoreSplits.contains(planNodeId)) {
return;
}
noMoreSplits.add(planNodeId);
if (noMoreSplits.size() < sourceStartOrder.size()) {
return;
}
checkState(noMoreSplits.size() == sourceStartOrder.size());
checkState(noMoreSplits.containsAll(sourceStartOrder));
status.setNoMoreLifespans();
}
代码示例来源:origin: line/armeria
private OAuth1aToken(Map<String, String> params) {
// Map builder with default version value.
final ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
for (Entry<String, String> param : params.entrySet()) {
final String key = param.getKey();
final String value = param.getValue();
// Empty values are ignored.
if (!Strings.isNullOrEmpty(value)) {
final String lowerCased = Ascii.toLowerCase(key);
if (DEFINED_PARAM_KEYS.contains(lowerCased)) {
// If given parameter is defined by Oauth1a protocol, add with lower-cased key.
builder.put(lowerCased, value);
} else {
// Otherwise, just add.
builder.put(key, value);
}
}
}
this.params = builder.build();
if (!this.params.keySet().containsAll(REQUIRED_PARAM_KEYS)) {
final Set<String> missing = Sets.difference(REQUIRED_PARAM_KEYS, this.params.keySet());
throw new IllegalArgumentException("Missing OAuth1a parameter exists: " + missing);
}
try {
Long.parseLong(this.params.get(OAUTH_TIMESTAMP));
} catch (NumberFormatException e) {
throw new IllegalArgumentException(
"Illegal " + OAUTH_TIMESTAMP + " value: " + this.params.get(OAUTH_TIMESTAMP));
}
}
代码示例来源:origin: junit-team/junit4
/**
* Orders the descriptions.
*
* @return descriptions in order
*/
public List<Description> order(Collection<Description> descriptions)
throws InvalidOrderingException {
List<Description> inOrder = ordering.orderItems(
Collections.unmodifiableCollection(descriptions));
if (!ordering.validateOrderingIsCorrect()) {
return inOrder;
}
Set<Description> uniqueDescriptions = new HashSet<Description>(descriptions);
if (!uniqueDescriptions.containsAll(inOrder)) {
throw new InvalidOrderingException("Ordering added items");
}
Set<Description> resultAsSet = new HashSet<Description>(inOrder);
if (resultAsSet.size() != inOrder.size()) {
throw new InvalidOrderingException("Ordering duplicated items");
} else if (!resultAsSet.containsAll(uniqueDescriptions)) {
throw new InvalidOrderingException("Ordering removed items");
}
return inOrder;
}
代码示例来源:origin: apache/incubator-druid
.entity("Request body must contain a map of { partition:endOffset }")
.build();
} else if (!endOffsets.keySet().containsAll(offsets.keySet())) {
return Response.status(Response.Status.BAD_REQUEST)
.entity(
StringUtils.format(
"Request contains partitions not being handled by this task, my partitions: %s",
endOffsets.keySet()
if (entry.getValue().compareTo(nextOffsets.get(entry.getKey())) < 0) {
return Response.status(Response.Status.BAD_REQUEST)
.entity(
"End offset must be >= current offset for partition [%s] (current: %s)",
entry.getKey(),
nextOffsets.get(entry.getKey())
代码示例来源:origin: robolectric/robolectric
@Override
public Account[] doWork()
throws OperationCanceledException, IOException, AuthenticatorException {
if (authenticationErrorOnNextResponse) {
setAuthenticationErrorOnNextResponse(false);
throw new AuthenticatorException();
}
List<Account> result = new ArrayList<>();
Account[] accountsByType = getAccountsByType(type);
for (Account account : accountsByType) {
Set<String> featureSet = accountFeatures.get(account);
if (features == null || featureSet.containsAll(Arrays.asList(features))) {
result.add(account);
}
}
return result.toArray(new Account[result.size()]);
}
});
代码示例来源:origin: apache/kylin
private static void tryDimensionAsMeasures(Collection<FunctionDesc> unmatchedAggregations, CapabilityResult result,
Set<TblColRef> dimCols) {
Iterator<FunctionDesc> it = unmatchedAggregations.iterator();
while (it.hasNext()) {
FunctionDesc functionDesc = it.next();
// let calcite handle count
if (functionDesc.isCount()) {
it.remove();
continue;
}
// calcite can do aggregation from columns on-the-fly
ParameterDesc parameterDesc = functionDesc.getParameter();
if (parameterDesc == null) {
continue;
}
List<TblColRef> neededCols = parameterDesc.getColRefs();
if (neededCols.size() > 0 && dimCols.containsAll(neededCols)
&& FunctionDesc.BUILT_IN_AGGREGATIONS.contains(functionDesc.getExpression())) {
result.influences.add(new CapabilityResult.DimensionAsMeasure(functionDesc));
it.remove();
continue;
}
}
}
代码示例来源:origin: org.mongodb/mongo-java-driver
@Override
public boolean containsAll(final Collection collection) {
Set<Object> values = new HashSet<Object>();
for (final Object o : this) {
values.add(o);
}
return values.containsAll(collection);
}
代码示例来源:origin: spotbugs/spotbugs
@ExpectWarning("DMI")
public static void main(String args[]) {
Set s = new HashSet();
s.contains(s);
s.remove(s);
s.removeAll(s);
s.retainAll(s);
s.containsAll(s);
Map m = new HashMap();
m.get(m);
m.remove(m);
m.containsKey(m);
m.containsValue(m);
List lst = new LinkedList();
lst.indexOf(lst);
lst.lastIndexOf(lst);
}
代码示例来源:origin: apache/ignite
/**
* @param presentedNodes Nodes present in cluster.
* @return {@code True} if current topology satisfies baseline.
*/
public boolean isSatisfied(@NotNull Collection<ClusterNode> presentedNodes) {
if (presentedNodes.size() < nodeMap.size())
return false;
Set<Object> presentedNodeIds = new HashSet<>();
for (ClusterNode node : presentedNodes)
presentedNodeIds.add(node.consistentId());
return presentedNodeIds.containsAll(nodeMap.keySet());
}
代码示例来源:origin: spotbugs/spotbugs
/**
* @param args
*/
@ExpectWarning("DMI,GC")
public static void main(String args[]) {
Set<A> sa = new HashSet<A>();
Set<A> sa2 = new HashSet<A>();
TreeSet<A> tsa2 = new TreeSet<A>();
sa.contains(sa);
sa.contains(sa2);
sa.contains(tsa2);
sa.containsAll(sa);
sa.containsAll(sa2);
sa.containsAll(tsa2);
}
}
代码示例来源:origin: Graylog2/graylog2-server
boolean hasWildcardPermission = permissionSet.contains("*");
if (hasWildcardPermission && !user.getRoleIds().contains(adminRoleId)) {
fixedRoleIds.add(adminRoleId);
final boolean hasCompleteReaderSet = permissionSet.containsAll(basePermissions);
continue;
if (hasCompleteReaderSet && !user.getRoleIds().contains(readerRoleId)) {
fixedRoleIds.add(readerRoleId);
代码示例来源:origin: skylot/jadx
private static boolean canSelectNext(IfInfo info, BlockNode block) {
if (block.getPredecessors().size() == 1) {
return true;
}
if (info.getMergedBlocks().containsAll(block.getPredecessors())) {
return true;
}
return false;
}
代码示例来源:origin: stagemonitor/stagemonitor
static void initializePluginsInOrder(Collection<String> disabledPlugins, Iterable<StagemonitorPlugin> plugins) {
Set<Class<? extends StagemonitorPlugin>> alreadyInitialized = new HashSet<Class<? extends StagemonitorPlugin>>();
Set<StagemonitorPlugin> notYetInitialized = getPluginsToInit(disabledPlugins, plugins);
while (!notYetInitialized.isEmpty()) {
int countNotYetInitialized = notYetInitialized.size();
// try to init plugins which are
for (Iterator<StagemonitorPlugin> iterator = notYetInitialized.iterator(); iterator.hasNext(); ) {
StagemonitorPlugin stagemonitorPlugin = iterator.next();
{
final List<Class<? extends StagemonitorPlugin>> dependencies = stagemonitorPlugin.dependsOn();
if (dependencies.isEmpty() || alreadyInitialized.containsAll(dependencies)) {
initializePlugin(stagemonitorPlugin);
iterator.remove();
alreadyInitialized.add(stagemonitorPlugin.getClass());
}
}
}
if (countNotYetInitialized == notYetInitialized.size()) {
// no plugins could be initialized in this try. this probably means there is a cyclic dependency
throw new IllegalStateException("Cyclic dependencies detected: " + notYetInitialized);
}
}
}
代码示例来源:origin: ehcache/ehcache3
@Test
public void testKeysForSynchronization() throws Exception {
final int concurrency = 111;
ConcurrencyStrategy<EhcacheEntityMessage> strategy = ConcurrencyStrategies.clusterTierConcurrency(DEFAULT_MAPPER);
Set<Integer> visitedConcurrencyKeys = new HashSet<>();
for (int i = -1024; i < 1024; i++) {
int concurrencyKey = strategy.concurrencyKey(new ConcurrentTestEntityMessage(i));
assertThat(concurrencyKey, withinRange(DEFAULT_KEY, concurrency));
visitedConcurrencyKeys.add(concurrencyKey);
}
Set<Integer> keysForSynchronization = strategy.getKeysForSynchronization();
assertThat(keysForSynchronization.contains(DEFAULT_KEY), is(true));
assertThat(keysForSynchronization.containsAll(visitedConcurrencyKeys), is(true));
}
代码示例来源:origin: prestodb/presto
@Override
public Void visitIndexJoin(IndexJoinNode node, Set<Symbol> boundSymbols)
{
node.getProbeSource().accept(this, boundSymbols);
node.getIndexSource().accept(this, boundSymbols);
Set<Symbol> probeInputs = createInputs(node.getProbeSource(), boundSymbols);
Set<Symbol> indexSourceInputs = createInputs(node.getIndexSource(), boundSymbols);
for (IndexJoinNode.EquiJoinClause clause : node.getCriteria()) {
checkArgument(probeInputs.contains(clause.getProbe()), "Probe symbol from index join clause (%s) not in probe source (%s)", clause.getProbe(), node.getProbeSource().getOutputSymbols());
checkArgument(indexSourceInputs.contains(clause.getIndex()), "Index symbol from index join clause (%s) not in index source (%s)", clause.getIndex(), node.getIndexSource().getOutputSymbols());
}
Set<Symbol> lookupSymbols = node.getCriteria().stream()
.map(IndexJoinNode.EquiJoinClause::getIndex)
.collect(toImmutableSet());
Map<Symbol, Symbol> trace = IndexKeyTracer.trace(node.getIndexSource(), lookupSymbols);
checkArgument(!trace.isEmpty() && lookupSymbols.containsAll(trace.keySet()),
"Index lookup symbols are not traceable to index source: %s",
lookupSymbols);
return null;
}
代码示例来源:origin: apache/kafka
for (Assignment assigned : assignment.values()) {
for (TopicPartition tp : assigned.partitions())
assignedTopics.add(tp.topic());
if (!assignedTopics.containsAll(allSubscribedTopics)) {
Set<String> notAssignedTopics = new HashSet<>(allSubscribedTopics);
notAssignedTopics.removeAll(assignedTopics);
if (!allSubscribedTopics.containsAll(assignedTopics)) {
Set<String> newlyAddedTopics = new HashSet<>(assignedTopics);
newlyAddedTopics.removeAll(allSubscribedTopics);
代码示例来源:origin: SonarSource/sonarqube
/**
* Validates tags and resolves conflicts between user and system tags.
*/
static boolean applyTags(RuleDto rule, Set<String> tags) {
for (String tag : tags) {
RuleTagFormat.validate(tag);
}
Set<String> initialTags = rule.getTags();
final Set<String> systemTags = rule.getSystemTags();
Set<String> withoutSystemTags = Sets.filter(tags, input -> input != null && !systemTags.contains(input));
rule.setTags(withoutSystemTags);
return withoutSystemTags.size() != initialTags.size() || !withoutSystemTags.containsAll(initialTags);
}
}
代码示例来源:origin: commons-collections/commons-collections
public void verifyKeySet() {
int size = confirmed.size();
boolean empty = confirmed.isEmpty();
assertEquals("keySet should be same size as HashMap's" +
"\nTest: " + keySet + "\nReal: " + confirmed.keySet(),
size, keySet.size());
assertEquals("keySet should be empty if HashMap is" +
"\nTest: " + keySet + "\nReal: " + confirmed.keySet(),
empty, keySet.isEmpty());
assertTrue("keySet should contain all HashMap's elements" +
"\nTest: " + keySet + "\nReal: " + confirmed.keySet(),
keySet.containsAll(confirmed.keySet()));
assertEquals("keySet hashCodes should be the same" +
"\nTest: " + keySet + "\nReal: " + confirmed.keySet(),
confirmed.keySet().hashCode(), keySet.hashCode());
assertEquals("Map's key set should still equal HashMap's",
confirmed.keySet(), keySet);
}
内容来源于网络,如有侵权,请联系作者删除!