当前位置: 首页>>代码示例>>Java>>正文


Java Sets.intersection方法代码示例

本文整理汇总了Java中com.google.common.collect.Sets.intersection方法的典型用法代码示例。如果您正苦于以下问题:Java Sets.intersection方法的具体用法?Java Sets.intersection怎么用?Java Sets.intersection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.Sets的用法示例。


在下文中一共展示了Sets.intersection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: formatConfiguration

import com.google.common.collect.Sets; //导入方法依赖的package包/类
static void formatConfiguration(StringBuilder sb, AttributeContainer fromConfigurationAttributes, AttributesSchema consumerSchema, List<ConfigurationMetadata> matches, Set<String> requestedAttributes, int maxConfLength, final String conf) {
    Optional<ConfigurationMetadata> match = Iterables.tryFind(matches, new Predicate<ConfigurationMetadata>() {
        @Override
        public boolean apply(ConfigurationMetadata input) {
            return conf.equals(input.getName());
        }
    });
    if (match.isPresent()) {
        AttributeContainer producerAttributes = match.get().getAttributes();
        Set<Attribute<?>> targetAttributes = producerAttributes.keySet();
        Set<String> targetAttributeNames = Sets.newTreeSet(Iterables.transform(targetAttributes, ATTRIBUTE_NAME));
        Set<Attribute<?>> allAttributes = Sets.union(fromConfigurationAttributes.keySet(), producerAttributes.keySet());
        Set<String> commonAttributes = Sets.intersection(requestedAttributes, targetAttributeNames);
        Set<String> consumerOnlyAttributes = Sets.difference(requestedAttributes, targetAttributeNames);
        sb.append("   ").append("- Configuration '").append(StringUtils.rightPad(conf + "'", maxConfLength + 1)).append(" :");
        List<Attribute<?>> sortedAttributes = Ordering.usingToString().sortedCopy(allAttributes);
        List<String> values = new ArrayList<String>(sortedAttributes.size());
        formatAttributes(sb, fromConfigurationAttributes, consumerSchema, producerAttributes, commonAttributes, consumerOnlyAttributes, sortedAttributes, values);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:AmbiguousConfigurationSelectionException.java

示例2: computeEdgeColors

import com.google.common.collect.Sets; //导入方法依赖的package包/类
/**
 * Computes the {@link Color} of the {@link Edge}.
 *
 * @param edge the {@link Edge}
 * @return list of {@link Edge} colors
 */
private List<Color> computeEdgeColors(final Edge edge) {
    final List<Color> edgeColors;

    if (edge.getFromSegment().equals(hoveredSegmentProperty.get())
            || edge.getToSegment().equals(hoveredSegmentProperty.get())) {
        edgeColors = Collections.singletonList(HighlightType.HIGHLIGHTED.getColor());
    } else if (edge.getGenomes() != null
            && graphDimensionsCalculator.getRadiusProperty().get() < MAX_PATH_THICKNESS_DRAWING_RADIUS) {
        final Set<String> selectedGenomesInEdge
                = Sets.intersection(edge.getGenomes(), selectedGenomePaths.keySet());

        if (selectedGenomesInEdge.isEmpty()) {
            edgeColors = Collections.singletonList(getEdgeColor());
        } else {
            edgeColors = selectedGenomesInEdge.stream()
                    .map(path -> correctColorForEdgeOpacity(selectedGenomePaths.get(path)))
                    .collect(Collectors.toList());
        }
    } else {
        edgeColors = Collections.singletonList(getEdgeColor());
    }

    return edgeColors;
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:31,代码来源:GraphVisualizer.java

示例3: createRegistry

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private <T extends IForgeRegistryEntry<T>> FMLControlledNamespacedRegistry<T> createRegistry(ResourceLocation registryName, Class<T> type, ResourceLocation defaultObjectKey, int minId, int maxId, IForgeRegistry.AddCallback<T> addCallback, IForgeRegistry.ClearCallback<T> clearCallback, IForgeRegistry.CreateCallback<T> createCallback, IForgeRegistry.SubstitutionCallback<T> substitutionCallback)
{
    Set<Class<?>> parents = Sets.newHashSet();
    findSuperTypes(type, parents);
    SetView<Class<?>> overlappedTypes = Sets.intersection(parents, registrySuperTypes.keySet());
    if (!overlappedTypes.isEmpty())
    {
        Class<?> foundType = overlappedTypes.iterator().next();
        FMLLog.severe("Found existing registry of type %1s named %2s, you cannot create a new registry (%3s) with type %4s, as %4s has a parent of that type", foundType, registrySuperTypes.get(foundType), registryName, type);
        throw new IllegalArgumentException("Duplicate registry parent type found - you can only have one registry for a particular super type");
    }
    FMLControlledNamespacedRegistry<T> fmlControlledNamespacedRegistry = new FMLControlledNamespacedRegistry<T>(defaultObjectKey, minId, maxId, type, registries, addCallback, clearCallback, createCallback, substitutionCallback);
    registries.put(registryName, fmlControlledNamespacedRegistry);
    registrySuperTypes.put(type, registryName);
    return getRegistry(registryName, type);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:PersistentRegistryManager.java

示例4: expandDerivRightwards

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private void expandDerivRightwards(Derivation leftChild) {
  if (parser.verbose(6))
    LogInfo.begin_track("Expanding rightward");
  Map<String, List<Rule>> rhsCategoriesToRules = parser.leftToRightSiblingMap.get(leftChild.cat);
  if (rhsCategoriesToRules != null) {
    for (int i = 1; leftChild.end + i <= numTokens; ++i) {
      Set<String> intersection = Sets.intersection(rhsCategoriesToRules.keySet(), chart[leftChild.end][leftChild.end + i].keySet());

      for (String rhsCategory : intersection) {
        List<Rule> compatibleRules = rhsCategoriesToRules.get(rhsCategory);
        List<Derivation> rightChildren = chart[leftChild.end][leftChild.end + i].get(rhsCategory);
        generateParentDerivations(leftChild, rightChildren, true, compatibleRules);
      }
    }
    // handle terminals
    if (leftChild.end < numTokens)
      handleTerminalExpansion(leftChild, false, rhsCategoriesToRules);
  }
  if (parser.verbose(6))
    LogInfo.end_track();
}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:22,代码来源:AbstractReinforcementParserState.java

示例5: expandDerivLeftwards

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private void expandDerivLeftwards(Derivation rightChild) {
  if (parser.verbose(5))
    LogInfo.begin_track("Expanding leftward");
  Map<String, List<Rule>> lhsCategorisToRules = parser.rightToLeftSiblingMap.get(rightChild.cat);
  if (lhsCategorisToRules != null) {
    for (int i = 1; rightChild.start - i >= 0; ++i) {
      Set<String> intersection = Sets.intersection(lhsCategorisToRules.keySet(), chart[rightChild.start - i][rightChild.start].keySet());

      for (String lhsCategory : intersection) {
        List<Rule> compatibleRules = lhsCategorisToRules.get(lhsCategory);
        List<Derivation> leftChildren = chart[rightChild.start - i][rightChild.start].get(lhsCategory);
        generateParentDerivations(rightChild, leftChildren, false, compatibleRules);
      }
    }
    // handle terminals
    if (rightChild.start > 0)
      handleTerminalExpansion(rightChild, true, lhsCategorisToRules);
  }
  if (parser.verbose(5))
    LogInfo.end_track();
}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:22,代码来源:AbstractReinforcementParserState.java

示例6: releaseResource

import com.google.common.collect.Sets; //导入方法依赖的package包/类
protected synchronized void releaseResource(Resource clusterResource,
    Resource resource, Set<String> nodeLabels) {
  // Update usedResources by labels
  if (null == nodeLabels || nodeLabels.isEmpty()) {
    queueUsage.decUsed(resource);
  } else {
    Set<String> anls = (accessibleLabels.contains(RMNodeLabelsManager.ANY))
        ? labelManager.getClusterNodeLabels() : accessibleLabels;
    for (String label : Sets.intersection(anls, nodeLabels)) {
      queueUsage.decUsed(label, resource);
    }
  }

  if (null == nodeLabels || nodeLabels.isEmpty()) {
    CSQueueUtils.updateQueueStatistics(resourceCalculator, this, getParent(),
        labelManager.getResourceByLabel(RMNodeLabelsManager.NO_LABEL, clusterResource), minimumAllocation);
  }
  --numContainers;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:AbstractCSQueue.java

示例7: findUsersWithRolesAndPermissions

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private Set<User> findUsersWithRolesAndPermissions(Set<Role> roles, Set<Permission> permissions) {
    Set<User> userWithRole = new HashSet<>();
    Set<User> userWithPermissionLevel = new HashSet<>();

    if(permissions.isEmpty() && roles.isEmpty())
        return new HashSet<>(userRepository.findAll());

    permissions.
        forEach(permission -> userWithPermissionLevel.addAll(permission.getUsers()));
    if (roles.isEmpty())
        return userWithPermissionLevel;
    else {
        roles.forEach(role -> userWithRole.addAll(role.getUsers()));
        return Sets.intersection(userWithPermissionLevel, userWithRole);
    }
}
 
开发者ID:tosinoni,项目名称:SECP,代码行数:17,代码来源:GroupController.java

示例8: formatMessage

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private String formatMessage(long extraSleepTime, Map<String, GcTimes> gcTimesAfterSleep,
    Map<String, GcTimes> gcTimesBeforeSleep) {

  Set<String> gcBeanNames = Sets.intersection(gcTimesAfterSleep.keySet(),
    gcTimesBeforeSleep.keySet());
  List<String> gcDiffs = Lists.newArrayList();
  for (String name : gcBeanNames) {
    GcTimes diff = gcTimesAfterSleep.get(name).subtract(gcTimesBeforeSleep.get(name));
    if (diff.gcCount != 0) {
      gcDiffs.add("GC pool '" + name + "' had collection(s): " + diff.toString());
    }
  }

  String ret = "Detected pause in JVM or host machine (eg GC): " + "pause of approximately "
      + extraSleepTime + "ms\n";
  if (gcDiffs.isEmpty()) {
    ret += "No GCs detected";
  } else {
    ret += Joiner.on("\n").join(gcDiffs);
  }
  return ret;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:JvmPauseMonitor.java

示例9: subOntology

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Override
public Ontology<T, R> subOntology(TermId subOntologyRoot) {
  final Set<TermId> childTermIds = OntologyTerms.childrenOf(subOntologyRoot, this);
  final ImmutableDirectedGraph<TermId, ImmutableEdge<TermId>> subGraph =
      (ImmutableDirectedGraph<TermId, ImmutableEdge<TermId>>) graph.subGraph(childTermIds);
  return new ImmutableOntology<T, R>(metaInfo, subGraph, subOntologyRoot,
      Sets.intersection(nonObsoleteTermIds, childTermIds),
      Sets.intersection(obsoleteTermIds, childTermIds), termMap, relationMap);
}
 
开发者ID:johntiger1,项目名称:boqa,代码行数:10,代码来源:ImmutableOntology.java

示例10: findMplsLabels

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private Map<LinkKey, MplsLabel> findMplsLabels(PathCompilerCreateFlow creator, Set<LinkKey> links) {
    Map<LinkKey, MplsLabel> labels = new HashMap<>();
    for (LinkKey link : links) {
        Set<MplsLabel> forward = findMplsLabel(creator, link.src());
        Set<MplsLabel> backward = findMplsLabel(creator, link.dst());
        Set<MplsLabel> common = Sets.intersection(forward, backward);
        if (common.isEmpty()) {
            continue;
        }
        labels.put(link, common.iterator().next());
    }

    return labels;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:PathCompiler.java

示例11: trueMain

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private static void trueMain(String[] argv) throws IOException {
  final Parameters params = Parameters.loadSerifStyle(new File(argv[0]));
  final File inputStore = params.getExistingDirectory("input1");
  final File inputStore2 = params.getExistingDirectory("input2");
  final File outputStore = params.getCreatableDirectory("outputStore");
  final boolean changeDuplicatedIDs = params.getOptionalBoolean("changeDuplicatedIDs").or(false);

  final SystemOutputStore2016 input1 = SystemOutputStore2016.open(inputStore);
  final SystemOutputStore2016 input2 = SystemOutputStore2016.open(inputStore2);
  final SystemOutputStore2016 output = SystemOutputStore2016.openOrCreate(outputStore);

  final Set<Symbol> commonDocIDs = Sets.intersection(input1.docIDs(), input2.docIDs());
  if (!commonDocIDs.isEmpty()) {
    if (changeDuplicatedIDs) {
      log.warn("Duplicated document IDs found! {}", commonDocIDs);
    } else {
      throw new TACKBPEALException(
          "Can only merge disjoint system output stores, but the following"
              + "docIDs are shared: " + commonDocIDs);
    }
  }

  // merge document-level output
  for (final SystemOutputStore2016 input : ImmutableList.of(input1, input2)) {
    for (final Symbol docID : input.docIDs()) {
      output.write(input.read(docID));
    }
  }

  // merge corpus-event frames
  output.writeCorpusEventFrames(
      merge(input1.readCorpusEventFrames(), input2.readCorpusEventFrames(), changeDuplicatedIDs));

  input1.close();
  input2.close();
  output.close();
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:38,代码来源:MergeSystemOutputs.java

示例12: AgreeSet

import com.google.common.collect.Sets; //导入方法依赖的package包/类
public AgreeSet(Set<Point> set1, Set<Point> set2, long numberOfColumns) {
	super(numberOfColumns);
	Set<Point> intersected = Sets.intersection(set1, set2);
	for (Point columnToIdentifier : intersected) {
		this.set(columnToIdentifier.x);
	}
}
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:8,代码来源:AgreeSet.java

示例13: intersection

import com.google.common.collect.Sets; //导入方法依赖的package包/类
static <T> Set<T> intersection(Set<T> a, Set<T> b) {
	// Smaller set first for performance improvement.
	// See: MathCaliper and note at Sets.intersection
	if (a.size() < b.size()) {
		return Sets.intersection(a, b);
	}

	return Sets.intersection(b, a);
}
 
开发者ID:janmotl,项目名称:linkifier,代码行数:10,代码来源:Math.java

示例14: diff

import com.google.common.collect.Sets; //导入方法依赖的package包/类
public static List<Set<String>> diff(HeaderGroup expected, HeaderGroup actual) {
	Set<String> expecetdKeys = keys(expected);
	Set<String> actualKeys = keys(actual);
	Set<String> common = Sets.intersection(expecetdKeys, actualKeys);
	Set<String> symdiff = Sets.symmetricDifference(expecetdKeys, actualKeys);
	Set<String> diffval = new HashSet<>();
	for (String s : common)
		if (! expected.getCondensedHeader(s).getValue().equals(actual.getCondensedHeader(s).getValue())) diffval.add(s);
	return Arrays.asList(diffval, symdiff);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:11,代码来源:InputStreamTestMocks.java

示例15: execute

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Override
public void execute(final Berichtgegevens berichtgegevens) {
    // geautoriseerde acties weten we
    final Set<Actie> geautoriseerdeActies = bepaalActiesVanGeautoriseerdeAttributen(berichtgegevens);
    final Set<Actie> geautoriseerdeActiesMetHandelingen = Sets.newHashSet();
    // acties uit de administratieve handelingen
    final Set<AdministratieveHandeling> geautoriseerdeHandelingen = Sets.newHashSet();
    for (final AdministratieveHandeling handeling : berichtgegevens.getPersoonslijst().getAdministratieveHandelingen()) {
        if (berichtgegevens.isMutatiebericht() && !handeling.getId().equals(berichtgegevens.getParameters().getAdministratieveHandeling())) {
            // voor mutatielevering alleen de huidige handeling in acht nemen
            continue;

        }
        final Collection<Actie> acties = handeling.getActies();
        final Sets.SetView<Actie> gedeeldeActies = Sets.intersection(geautoriseerdeActies, Sets.newHashSet(acties));
        if (!gedeeldeActies.isEmpty()) {
            geautoriseerdeHandelingen.add(handeling);
            geautoriseerdeActiesMetHandelingen.addAll(gedeeldeActies);
        }
    }
    // update LeverPersoon met geautoriseerde acties die ook handelingen hebben
    berichtgegevens.setGeautoriseerdeActies(geautoriseerdeActiesMetHandelingen);
    // update LeverPersoon met geautoriseerde handelingen
    berichtgegevens.setGeautoriseerdeHandelingen(geautoriseerdeHandelingen);

    // verantwoordingattributen alleen leveren als de Actie geautoriseerd is
    for (final MetaAttribuut attribuut : berichtgegevens.getGeautoriseerdeAttributen()) {
        if (attribuut.getAttribuutElement().isVerantwoording() && !geautoriseerdeActiesMetHandelingen.contains(attribuut.<Actie>getWaarde())) {
            berichtgegevens.verwijderAutorisatie(attribuut);
        }
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:33,代码来源:VerantwoordingAutorisatieServiceImpl.java


注:本文中的com.google.common.collect.Sets.intersection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。