Example usage for com.google.common.collect Sets difference

List of usage examples for com.google.common.collect Sets difference

Introduction

In this page you can find the example usage for com.google.common.collect Sets difference.

Prototype

public static <E> SetView<E> difference(final Set<E> set1, final Set<?> set2) 

Source Link

Document

Returns an unmodifiable view of the difference of two sets.

Usage

From source file:org.caleydo.view.domino.internal.data.Numerical1DMixin.java

public static TypedGroupSet extractGroups(Perspective p, INumerical1DContainer c) {
    Set<Integer> invalid = new BitSetSet();
    TypedSet d = TypedSet.of(p.getVirtualArray());
    for (Integer id : d) {
        float v = c.getNormalized(id);
        if (Float.isInfinite(v) || Float.isNaN(v))
            invalid.add(id);//from   w w w.j a  v  a2s . c o m
    }
    if (invalid.isEmpty())
        return TypedGroupSet.createUngrouped(d);

    TypedSetGroup normal = new TypedSetGroup(
            new TypedSet(ImmutableSet.copyOf(Sets.difference(d, invalid)), d.getIdType()), "Normal",
            c.getColor());
    TypedSetGroup invalidG = new TypedSetGroup(new TypedSet(ImmutableSet.copyOf(invalid), d.getIdType()), "NaN",
            Color.NOT_A_NUMBER_COLOR);
    return new TypedGroupSet(normal, invalidG);
}

From source file:org.tensorics.core.analysis.lang.OngoingAllBooleanExcludableCondition.java

public OngoingAllBooleanExcludableCondition excluding(Set<Expression<Boolean>> excludedExpressions) {
    return new OngoingAllBooleanExcludableCondition(builder,
            ImmutableSet.copyOf(Sets.difference(sources, excludedExpressions)));
}

From source file:com.facebook.buck.cxx.CxxBinaryFlavored.java

@Override
public boolean hasFlavors(ImmutableSet<Flavor> inputFlavors) {
    Set<Flavor> flavors = inputFlavors;

    Set<Flavor> platformFlavors = Sets.intersection(flavors,
            Sets.union(getCxxPlatformsProvider().getUnresolvedCxxPlatforms().getFlavors(),
                    cxxBuckConfig.getDeclaredPlatforms()));
    if (platformFlavors.size() > 1) {
        return false;
    }/*w  w w . j a va 2  s. c om*/
    flavors = Sets.difference(flavors, platformFlavors);

    flavors = Sets.difference(flavors, ImmutableSet.of(CxxDescriptionEnhancer.CXX_LINK_MAP_FLAVOR,
            CxxDescriptionEnhancer.HEADER_SYMLINK_TREE_FLAVOR, CxxCompilationDatabase.COMPILATION_DATABASE,
            CxxCompilationDatabase.UBER_COMPILATION_DATABASE, CxxInferEnhancer.InferFlavors.INFER.getFlavor(),
            CxxInferEnhancer.InferFlavors.INFER_ANALYZE.getFlavor(),
            CxxInferEnhancer.InferFlavors.INFER_CAPTURE_ALL.getFlavor(), StripStyle.ALL_SYMBOLS.getFlavor(),
            StripStyle.DEBUGGING_SYMBOLS.getFlavor(), StripStyle.NON_GLOBAL_SYMBOLS.getFlavor(),
            LinkerMapMode.NO_LINKER_MAP.getFlavor()));

    return flavors.isEmpty();
}

From source file:com.google.errorprone.scanner.ScannerSupplierImpl.java

ScannerSupplierImpl(ImmutableBiMap<String, BugCheckerInfo> checks,
        ImmutableMap<String, BugPattern.SeverityLevel> severities, ImmutableSet<String> disabled) {
    checkArgument(Sets.difference(severities.keySet(), checks.keySet()).isEmpty(),
            "enabledChecks must be a subset of allChecks");
    checkArgument(Sets.difference(disabled, checks.keySet()).isEmpty(),
            "disabled must be a subset of allChecks");
    this.checks = checks;
    this.severities = severities;
    this.disabled = disabled;
}

From source file:org.eclipse.viatra.query.runtime.localsearch.planner.cost.EvaluablePConstraint.java

@Override
public boolean apply(PConstraint input) {
    if (input instanceof Inequality) {
        return Sets.difference(input.getAffectedVariables(), plan.getAllDeducedVariables()).isEmpty();
    } else if (input instanceof ExpressionEvaluation) {
        PVariable output = ((ExpressionEvaluation) input).getOutputVariable();

        final ImmutableSet<PVariable> outputs = (output == null) ? ImmutableSet.<PVariable>of()
                : ImmutableSet.of(output);

        Set<PVariable> inputVariables = Sets.difference(input.getAffectedVariables(), outputs);
        return Sets.difference(inputVariables, plan.getAllDeducedVariables()).isEmpty();

    } else if (input instanceof ExportedParameter) {
        return plan.getAllDeducedVariables().contains(((ExportedParameter) input).getParameterVariable());
    } else if (input instanceof TypeConstraint) {
        if (!allowInverseNavigation && ((TypeConstraint) input).getSupplierKey().getArity() == 2) {
            Tuple variables = ((TypeConstraint) input).getVariablesTuple();
            if (!plan.getAllDeducedVariables().contains(variables.get(0))) {
                return false;
            }//w  ww.  ja v a 2  s. c  o  m
        }
    }
    return true;
}

From source file:com.codemacro.jcm.storage.ClusterStorage.java

@Override
void onListChanged() {
    Set<String> names = new HashSet<String>(getChildren());
    logger.info("cluster list changed {}", names.size());
    Set<String> existed = clusterManager.getNames();
    Set<String> added = Sets.difference(names, existed);
    for (String name : added) {
        loadCluster(name);/*  w  ww  .  ja v  a  2  s.c  o m*/
    }
    Set<String> removed = Sets.difference(existed, names);
    for (String name : removed) {
        clusterManager.remove(name);
    }
    if (healthCheckManager != null) {
        healthCheckManager.onClusterListChanged();
    }
}

From source file:org.spf4j.ds.Traversals.java

public static <V, E> void traverse(final Graph<V, E> graph, final V startNode,
        final TraversalCallback<V, E> handler, final boolean isBreadth) {
    Set<V> traversedNodes = new HashSet<V>();
    Deque<V> traversalQueue = new ArrayDeque<V>();
    traversalQueue.add(startNode);/* ww w . j av  a  2  s  .  c o  m*/
    boolean done = false;
    do {
        boolean first = true;
        while (!traversalQueue.isEmpty()) {
            V node;
            if (isBreadth) {
                node = traversalQueue.removeFirst();
            } else {
                node = traversalQueue.removeLast();
            }
            VertexEdges<V, E> edges = graph.getEdges(node);
            if (traversedNodes.contains(node)) {
                continue;
            }
            Map<E, V> incomming = edges.getIncomming();
            boolean hasIncomingBeenTraversed = true;
            for (V val : incomming.values()) {
                if (!traversedNodes.contains(val)) {
                    hasIncomingBeenTraversed = false;
                    break;
                }
            }
            if (!first && !hasIncomingBeenTraversed) {
                continue;
            }
            handler.handle(node, incomming);
            traversedNodes.add(node);
            first = false;
            Map<E, V> outgoing = edges.getOutgoing();
            for (V next : outgoing.values()) {
                traversalQueue.add(next);
            }
        }

        Set<V> leftNodes = Sets.difference(graph.getVertices(), traversedNodes);
        if (leftNodes.isEmpty()) {
            done = true;
        } else {
            boolean added = false;
            for (V node : leftNodes) {
                Collection<V> incomingNodes = graph.getEdges(node).getIncomming().values();
                for (V incoming : incomingNodes) {
                    if (traversedNodes.contains(incoming)) {
                        traversalQueue.add(node);
                        added = true;
                        break;
                    }
                }
                if (added) {
                    break;
                }
            }
        }
    } while (!done);
}

From source file:terrastore.cluster.ensemble.impl.View.java

public int percentageOfChange(View anotherView) {
    Set<Member> a = new HashSet<Member>(members);
    Set<Member> b = new HashSet<Member>(anotherView.getMembers());
    int abDifference = Sets.difference(a, b).size();
    int baDifference = Sets.difference(b, a).size();
    int abUnion = Sets.union(a, b).size();
    return (int) (((float) (abDifference + baDifference) / abUnion) * 100);
}

From source file:com.google.devtools.build.docgen.SinglePageBuildEncyclopediaProcessor.java

/**
 * Collects and processes all the rule and attribute documentation in inputDirs and
 * generates the Build Encyclopedia into the outputDir.
 *
 * @param inputDirs list of directory to scan for document in the source code
 * @param outputDir output directory where to write the build encyclopedia
 * @param blackList optional path to a file listing rules to not document
 *//*from   ww  w  . ja  v  a 2 s.c o m*/
@Override
public void generateDocumentation(List<String> inputDirs, String outputDir, String blackList)
        throws BuildEncyclopediaDocException, IOException {
    BuildDocCollector collector = new BuildDocCollector(ruleClassProvider, false);
    RuleLinkExpander expander = new RuleLinkExpander(ruleClassProvider.getProductName(), true);
    Map<String, RuleDocumentation> ruleDocEntries = collector.collect(inputDirs, blackList, expander);
    warnAboutUndocumentedRules(
            Sets.difference(ruleClassProvider.getRuleClassMap().keySet(), ruleDocEntries.keySet()));
    RuleFamilies ruleFamilies = assembleRuleFamilies(ruleDocEntries.values());

    Page page = TemplateEngine.newPage(DocgenConsts.SINGLE_BE_TEMPLATE);

    // Add the rule link expander.
    page.add("expander", expander);

    // Populate variables for Common Definitions section.
    page.add("commonAttributes", expandCommonAttributes(PredefinedAttributes.COMMON_ATTRIBUTES, expander));
    page.add("testAttributes", expandCommonAttributes(PredefinedAttributes.TEST_ATTRIBUTES, expander));
    page.add("binaryAttributes", expandCommonAttributes(PredefinedAttributes.BINARY_ATTRIBUTES, expander));

    // Popualte variables for Overview section.
    page.add("langSpecificRuleFamilies", ruleFamilies.langSpecific);
    page.add("genericRuleFamilies", ruleFamilies.generic);

    // Populate variables for Rules section.
    page.add("ruleFamilies", ruleFamilies.all);
    page.add("singlePage", true);

    writePage(page, outputDir, "build-encyclopedia.html");
}

From source file:au.edu.uq.nmerge.mvd.CompactNode.java

/**
 * Compute the difference between incoming, outgoing
 *
 * @return the difference
 */
Set<Witness> getWantsOutgoing() {
    return Sets.newHashSet(Sets.difference(incoming, outgoing));
}