java.util.Collections.disjoint()方法的使用及代码示例

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

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

Collections.disjoint介绍

[英]Returns whether the specified collections have no elements in common.
[中]返回指定集合是否没有公共元素。

代码示例

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

@Override
public boolean isEmpty() {
 return Collections.disjoint(set1, set2);
}

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

private static boolean intersect(Set<?> a, Set<?> b) {
 return !disjoint(a, b);
}

代码示例来源:origin: prestodb/presto

@Override
public boolean isEmpty() {
 return Collections.disjoint(set1, set2);
}

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * Returns true if there is at least element that is in both s1 and s2. Faster
 * than calling intersection(Set,Set) if you don't need the contents of the
 * intersection.
 */
public static <E> boolean intersects(Set<E> s1, Set<E> s2) {
 // *ahem* It would seem that Java already had this method. Hopefully this
 // stub will help people find it better than I did.
 return !Collections.disjoint(s1, s2);
}

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

@Override
public boolean isEmpty() {
 return Collections.disjoint(set1, set2);
}

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

private boolean hasTypeUseOrTypeParameter(Target targetAnnotation) {
 // Should only be in cases where Target is not in the classpath
 return targetAnnotation != null
   && !Collections.disjoint(FORBIDDEN_ELEMENT_TYPES, Arrays.asList(targetAnnotation.value()));
}

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

private static void checkConflict(
  String earlierRequirement,
  Set<Feature<?>> earlierFeatures,
  String newRequirement,
  Set<Feature<?>> newFeatures,
  Object source)
  throws ConflictingRequirementsException {
 if (!Collections.disjoint(newFeatures, earlierFeatures)) {
  throw new ConflictingRequirementsException(
    String.format(
      Locale.ROOT,
      "Annotation requires to be %s features that earlier "
        + "annotations required to be %s.",
      newRequirement,
      earlierRequirement),
    intersection(newFeatures, earlierFeatures),
    source);
 }
}

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

@Override
public boolean equals(Object other) {
  if (this == other) {
    return true;
  } else if (!(other instanceof Key)) {
    return false;
  }
  Key key = (Key) other;
  return internalName.equals(key.internalName)
      && parameterCount == key.parameterCount
      && !Collections.disjoint(getIdentifiers(), key.getIdentifiers());
}

代码示例来源:origin: MovingBlocks/Terasology

private static Graph getDisjointnessGraph(Map<String, Set<Block>> fields) {
  Graph graph = new Graph(fields.keySet().toArray(new String[0]));
  fields.forEach((name0, blockSet0) ->
    fields.forEach((name1, blockSet1) -> {
      if (name0.compareTo(name1) < 0 && Collections.disjoint(blockSet0, blockSet1)) {
        graph.addEdge(name0, name1);
      }
    })
  );
  return graph;
}

代码示例来源:origin: graphql-java/graphql-java

private boolean doTypesOverlap(GraphQLType type, GraphQLCompositeType parent) {
  if (type == parent) {
    return true;
  }
  List<? extends GraphQLType> possibleParentTypes = getPossibleType(parent);
  List<? extends GraphQLType> possibleConditionTypes = getPossibleType(type);
  return !Collections.disjoint(possibleParentTypes, possibleConditionTypes);
}

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

/**
 * Returns true if the given tree is annotated with a {@code @SuppressWarnings} that disables this
 * bug checker.
 */
public boolean isSuppressed(Tree tree) {
 SuppressWarnings suppression = ASTHelpers.getAnnotation(tree, SuppressWarnings.class);
 return suppression != null
   && !Collections.disjoint(Arrays.asList(suppression.value()), allNames());
}

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

/**
 * Returns true if the given symbol is annotated with a {@code @SuppressWarnings} that disables
 * this bug checker.
 */
public boolean isSuppressed(Symbol symbol) {
 SuppressWarnings suppression = ASTHelpers.getAnnotation(symbol, SuppressWarnings.class);
 return suppression != null
   && !Collections.disjoint(Arrays.asList(suppression.value()), allNames());
}

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

Set<Feature<?>> allAbsentFeatures =
  addImpliedFeatures(Helpers.<Feature<?>>copyToSet(absentFeatures));
if (!Collections.disjoint(allPresentFeatures, allAbsentFeatures)) {
 throw new ConflictingRequirementsException(
   "Annotation explicitly or "

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

/** Adds the files to compacting files. filesCompacting must be locked. */
private void addToCompactingFiles(Collection<HStoreFile> filesToAdd) {
 if (CollectionUtils.isEmpty(filesToAdd)) {
  return;
 }
 // Check that we do not try to compact the same StoreFile twice.
 if (!Collections.disjoint(filesCompacting, filesToAdd)) {
  Preconditions.checkArgument(false, "%s overlaps with %s", filesToAdd, filesCompacting);
 }
 filesCompacting.addAll(filesToAdd);
 Collections.sort(filesCompacting, storeEngine.getStoreFileManager().getStoreFileComparator());
}

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

TestSuite computeMultimapAsMapGetTestSuite(
  FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<M, Entry<K, V>>>
    parentBuilder) {
 Set<Feature<?>> features = computeMultimapAsMapGetFeatures(parentBuilder.getFeatures());
 if (Collections.disjoint(features, EnumSet.allOf(CollectionSize.class))) {
  return new TestSuite();
 } else {
  return CollectionTestSuiteBuilder.using(
      new MultimapAsMapGetGenerator<K, V, M>(parentBuilder.getSubjectGenerator()))
    .withFeatures(features)
    .named(parentBuilder.getName() + ".asMap[].get[key]")
    .suppressing(parentBuilder.getSuppressedTests())
    .createTestSuite();
 }
}

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

@Override
TestSuite computeMultimapAsMapGetTestSuite(
  FeatureSpecificTestSuiteBuilder<
      ?, ? extends OneSizeTestContainerGenerator<SetMultimap<K, V>, Entry<K, V>>>
    parentBuilder) {
 Set<Feature<?>> features = computeMultimapAsMapGetFeatures(parentBuilder.getFeatures());
 if (Collections.disjoint(features, EnumSet.allOf(CollectionSize.class))) {
  return new TestSuite();
 } else {
  return SetTestSuiteBuilder.using(
      new MultimapAsMapGetGenerator<K, V>(parentBuilder.getSubjectGenerator()))
    .withFeatures(features)
    .named(parentBuilder.getName() + ".asMap[].get[key]")
    .suppressing(parentBuilder.getSuppressedTests())
    .createTestSuite();
 }
}

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

@Override
TestSuite computeMultimapAsMapGetTestSuite(
  FeatureSpecificTestSuiteBuilder<
      ?, ? extends OneSizeTestContainerGenerator<ListMultimap<K, V>, Entry<K, V>>>
    parentBuilder) {
 Set<Feature<?>> features = computeMultimapAsMapGetFeatures(parentBuilder.getFeatures());
 if (Collections.disjoint(features, EnumSet.allOf(CollectionSize.class))) {
  return new TestSuite();
 } else {
  return ListTestSuiteBuilder.using(
      new MultimapAsMapGetGenerator<K, V>(parentBuilder.getSubjectGenerator()))
    .withFeatures(features)
    .named(parentBuilder.getName() + ".asMap[].get[key]")
    .suppressing(parentBuilder.getSuppressedTests())
    .createTestSuite();
 }
}

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

@Override
 TestSuite computeMultimapAsMapGetTestSuite(
   FeatureSpecificTestSuiteBuilder<
       ?, ? extends OneSizeTestContainerGenerator<SetMultimap<K, V>, Entry<K, V>>>
     parentBuilder) {
  Set<Feature<?>> features = computeMultimapAsMapGetFeatures(parentBuilder.getFeatures());
  if (Collections.disjoint(features, EnumSet.allOf(CollectionSize.class))) {
   return new TestSuite();
  } else {
   return SortedSetTestSuiteBuilder.using(
       new SetMultimapTestSuiteBuilder.MultimapAsMapGetGenerator<K, V>(
         parentBuilder.getSubjectGenerator()))
     .withFeatures(features)
     .named(parentBuilder.getName() + ".asMap[].get[key]")
     .suppressing(parentBuilder.getSuppressedTests())
     .createTestSuite();
  }
 }
}

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

@Override
  public void onMetadataUpdate(Cluster cluster, Set<String> unavailableTopics) {
    // if we encounter any unauthorized topics, raise an exception to the user
    if (!cluster.unauthorizedTopics().isEmpty())
      throw new TopicAuthorizationException(new HashSet<>(cluster.unauthorizedTopics()));
    // if we encounter any invalid topics, raise an exception to the user
    if (!cluster.invalidTopics().isEmpty())
      throw new InvalidTopicException(cluster.invalidTopics());
    if (subscriptions.hasPatternSubscription())
      updatePatternSubscription(cluster);
    // check if there are any changes to the metadata which should trigger a rebalance
    if (subscriptions.partitionsAutoAssigned()) {
      MetadataSnapshot snapshot = new MetadataSnapshot(subscriptions, cluster);
      if (!snapshot.equals(metadataSnapshot))
        metadataSnapshot = snapshot;
    }
    if (!Collections.disjoint(metadata.topics(), unavailableTopics))
      metadata.requestUpdate();
  }
});

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

@After
public void validateSourceAndTarget() {
 for (Integer node : network.nodes()) {
  for (String inEdge : network.inEdges(node)) {
   EndpointPair<Integer> endpointPair = network.incidentNodes(inEdge);
   assertThat(endpointPair.source()).isEqualTo(endpointPair.adjacentNode(node));
   assertThat(endpointPair.target()).isEqualTo(node);
  }
  for (String outEdge : network.outEdges(node)) {
   EndpointPair<Integer> endpointPair = network.incidentNodes(outEdge);
   assertThat(endpointPair.source()).isEqualTo(node);
   assertThat(endpointPair.target()).isEqualTo(endpointPair.adjacentNode(node));
  }
  for (Integer adjacentNode : network.adjacentNodes(node)) {
   Set<String> edges = network.edgesConnecting(node, adjacentNode);
   Set<String> antiParallelEdges = network.edgesConnecting(adjacentNode, node);
   assertThat(node.equals(adjacentNode) || Collections.disjoint(edges, antiParallelEdges))
     .isTrue();
  }
 }
}

相关文章

Collections类方法