List of usage examples for com.google.common.collect Sets intersection
public static <E> SetView<E> intersection(final Set<E> set1, final Set<?> set2)
From source file:org.caleydo.view.relationshipexplorer.ui.collection.AEntityCollection.java
@Override public void setFilteredItems(Set<Object> elementIDs) { this.filteredElementIDs = new HashSet<>(Sets.intersection(elementIDs, allElementIDs)); // notifyFilterUpdate(updateSource); }
From source file:net.hillsdon.reviki.wiki.graph.WikiGraphImpl.java
/** * The search index will only update its record of outgoing links * when pages are edited so we compensate by filtering. * * @param pages Incoming.// w w w .ja v a 2 s .c o m * @throws PageStoreException If we can't get the page list. */ private Set<String> onlyExistingPages(final Set<String> pages) throws PageStoreException { Set<String> allExisting = ImmutableSet .copyOf(Iterables.transform(_pageStore.list(), PageReference.TO_NAME)); return Sets.intersection(pages, allExisting); }
From source file:org.onosproject.t3.impl.PingAllGenerator.java
@Override protected void run() throws InterruptedException { hostService.getHosts().forEach(host -> { List<IpAddress> ipAddresses = manager.getIpAddresses(host, etherType, false); if (ipAddresses.size() > 0) { //check if the host has only local IPs of that ETH type boolean onlyLocalSrc = ipAddresses.size() == 1 && ipAddresses.get(0).isLinkLocal(); hostService.getHosts().forEach(hostToPing -> { List<IpAddress> ipAddressesToPing = manager.getIpAddresses(hostToPing, etherType, false); //check if the other host has only local IPs of that ETH type boolean onlyLocalDst = ipAddressesToPing.size() == 1 && ipAddressesToPing.get(0).isLinkLocal(); boolean sameLocation = Sets.intersection(host.locations(), hostToPing.locations()).size() > 0; //Trace is done only if they are both local and under the same location // or not local and if they are not the same host. if (((sameLocation && onlyLocalDst && onlyLocalSrc) || (!onlyLocalSrc && !onlyLocalDst && ipAddressesToPing.size() > 0)) && !host.equals(hostToPing)) { try { yield(manager.trace(host.id(), hostToPing.id(), etherType)); } catch (InterruptedException e) { log.warn("Interrupted generator", e.getMessage()); log.debug("exception", e); }// w w w . j a v a 2 s . c om } }); } }); }
From source file:com.facebook.presto.sql.planner.plan.GroupIdNode.java
@JsonCreator public GroupIdNode(@JsonProperty("id") PlanNodeId id, @JsonProperty("source") PlanNode source, @JsonProperty("groupingSets") List<List<Symbol>> groupingSets, @JsonProperty("groupingSetMappings") Map<Symbol, Symbol> groupingSetMappings, @JsonProperty("argumentMappings") Map<Symbol, Symbol> argumentMappings, @JsonProperty("groupIdSymbol") Symbol groupIdSymbol) { super(id);//from w w w. j a v a2s .com this.source = requireNonNull(source); this.groupingSets = listOfListsCopy(requireNonNull(groupingSets, "groupingSets is null")); this.groupingSetMappings = ImmutableMap.copyOf(requireNonNull(groupingSetMappings)); this.argumentMappings = ImmutableMap.copyOf(requireNonNull(argumentMappings)); this.groupIdSymbol = requireNonNull(groupIdSymbol); checkArgument(Sets.intersection(groupingSetMappings.keySet(), argumentMappings.keySet()).isEmpty(), "argument outputs and grouping outputs must be a disjoint set"); }
From source file:io.prestosql.sql.planner.plan.GroupIdNode.java
@JsonCreator public GroupIdNode(@JsonProperty("id") PlanNodeId id, @JsonProperty("source") PlanNode source, @JsonProperty("groupingSets") List<List<Symbol>> groupingSets, @JsonProperty("groupingColumns") Map<Symbol, Symbol> groupingColumns, @JsonProperty("aggregationArguments") List<Symbol> aggregationArguments, @JsonProperty("groupIdSymbol") Symbol groupIdSymbol) { super(id);//www .jav a 2 s . co m this.source = requireNonNull(source); this.groupingSets = listOfListsCopy(requireNonNull(groupingSets, "groupingSets is null")); this.groupingColumns = ImmutableMap.copyOf(requireNonNull(groupingColumns)); this.aggregationArguments = ImmutableList.copyOf(aggregationArguments); this.groupIdSymbol = requireNonNull(groupIdSymbol); checkArgument( Sets.intersection(groupingColumns.keySet(), ImmutableSet.copyOf(aggregationArguments)).isEmpty(), "aggregation columns and grouping set columns must be a disjoint set"); }
From source file:mvm.rya.indexing.IndexPlanValidator.VarConstantIndexListPruner.java
private boolean isRelevant(TupleExpr index) { ConstantCollector cc = new ConstantCollector(); index.visit(cc);// w w w . j a v a 2 s .co m Map<String, Integer> indexConstantMap = cc.getConstantMap(); int indexSpCount = cc.getSpCount(); int indexFilterCount = cc.getFilterCount(); Set<String> indexConstants = indexConstantMap.keySet(); if ((indexSpCount > querySpCount) || (indexFilterCount > queryFilterCount) || !(Sets.intersection(indexConstants, queryConstantMap.keySet()).equals(indexConstants))) { return false; } for (String s : indexConstants) { if (indexConstantMap.get(s) > queryConstantMap.get(s)) { return false; } } return true; }
From source file:com.google.javascript.jscomp.fuzzing.Dispatcher.java
protected AbstractFuzzer selectFuzzer(int budget, Set<Type> types) { Preconditions.checkNotNull(getCandidates(), "Candidate fuzzers need to be initialized before being used."); ArrayList<AbstractFuzzer> typeCorrectCandidates; typeCorrectCandidates = Lists.newArrayList(); for (AbstractFuzzer fuzzer : getCandidates()) { if (!Sets.intersection(fuzzer.supportedTypes(), types).isEmpty()) { typeCorrectCandidates.add(fuzzer); }//from w ww. j a v a 2s. c o m } JSONObject weightConfig = getOwnConfig().optJSONObject("weights"); ArrayList<AbstractFuzzer> validFuzzers = Lists.newArrayList(); ArrayList<Double> weights = Lists.newArrayList(); int stepSize = 2; budget -= stepSize; do { // increase the budget until it is enough for some fuzzers budget += stepSize; for (AbstractFuzzer fuzzer : typeCorrectCandidates) { if (fuzzer.isEnough(budget)) { validFuzzers.add(fuzzer); try { weights.add(weightConfig.getDouble(fuzzer.getConfigName())); } catch (JSONException e) { e.printStackTrace(); } } } } while (validFuzzers.isEmpty()); DiscreteDistribution<AbstractFuzzer> dd = new DiscreteDistribution<>(context.random, validFuzzers, weights); return dd.nextItem(); }
From source file:com.facebook.buck.cxx.CxxLibraryFlavored.java
@Override public boolean hasFlavors(ImmutableSet<Flavor> flavors) { return getCxxPlatformsProvider().getUnresolvedCxxPlatforms().containsAnyOf(flavors) || flavors.contains(CxxCompilationDatabase.COMPILATION_DATABASE) || flavors.contains(CxxCompilationDatabase.UBER_COMPILATION_DATABASE) || CxxInferEnhancer.INFER_FLAVOR_DOMAIN.containsAnyOf(flavors) || flavors.contains(CxxInferEnhancer.InferFlavors.INFER_ANALYZE.getFlavor()) || flavors.contains(CxxInferEnhancer.InferFlavors.INFER_CAPTURE_ALL.getFlavor()) || flavors.contains(CxxDescriptionEnhancer.EXPORTED_HEADER_SYMLINK_TREE_FLAVOR) || LinkerMapMode.FLAVOR_DOMAIN.containsAnyOf(flavors) || !Sets.intersection(cxxBuckConfig.getDeclaredPlatforms(), flavors).isEmpty(); }
From source file:org.wso2.carbon.governance.comparator.wsdl.WSDLMessagesComparator.java
protected void compareMessages(Definition base, Definition changed, DefaultComparison comparison) { DefaultComparison.DefaultSection section = null; Set<QName> baseKeys = base.getMessages().keySet(); Set<QName> changedKeys = changed.getMessages().keySet(); Set<QName> additionKeys = Sets.difference(changedKeys, baseKeys); if (section == null && additionKeys.size() > 0) { section = comparison.newSection(); }//from w ww .j a v a 2 s .c om processAdditions(section, additionKeys, changed); Set<QName> removalKeys = Sets.difference(baseKeys, changedKeys); if (section == null && removalKeys.size() > 0) { section = comparison.newSection(); } processRemovals(section, removalKeys, base); Set<QName> commonKeys = Sets.intersection(baseKeys, changedKeys); if (section == null && commonKeys.size() > 0) { section = comparison.newSection(); } processChanges(section, commonKeys, base, changed); if (section != null) { comparison.addSection(ComparatorConstants.WSDL_IMPORTS, section); } }
From source file:org.sonar.javascript.checks.DifferentTypesComparisonCheck.java
@Override public void beforeBlockElement(ProgramState currentState, Tree element) { if (element.is(Kind.STRICT_NOT_EQUAL_TO, Kind.STRICT_EQUAL_TO)) { BinaryExpressionTree comparison = (BinaryExpressionTree) element; Constraint rightConstraint = currentState.getConstraint(currentState.peekStack(0)); Constraint leftConstraint = currentState.getConstraint(currentState.peekStack(1)); Set<Type> rightType = rightConstraint.typeSet(); Set<Type> leftType = leftConstraint.typeSet(); boolean differentTypes = !rightType.isEmpty() && !leftType.isEmpty() && Sets.intersection(rightType, leftType).isEmpty(); if (!differentTypes) { typeDifference.put(comparison, false); } else if (!typeDifference.containsKey(comparison)) { typeDifference.put(comparison, true); }//from w w w . j a v a 2s . c o m } }