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

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

Introduction

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

Prototype

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

Source Link

Document

Returns an unmodifiable view of the union of two sets.

Usage

From source file:org.opendaylight.groupbasedpolicy.resolver.PolicyInfo.java

/**
 * Get the set of endpoint groups that are peers for the given endpoint
 * group//from   w  w  w.j  a  v a2s  .c  om
 * @param eg the endpoint group
 * @return the set of endpoint groups
 */
public Set<EgKey> getPeers(EgKey eg) {
    return Sets.union(policyMap.row(eg).keySet(), policyMap.column(eg).keySet());
}

From source file:prm4j.indexing.model.JoinArgs.java

public static JoinArgs[] createArgsArray(ParametricPropertyModel ppm, BaseEvent baseEvent) {
    final JoinArgs[] result = new JoinArgs[ppm.getJoinTuples().get(baseEvent).size()];
    final Table<Set<Parameter<?>>, Set<Parameter<?>>, Integer> monitorSetIds = ppm.getMonitorSetIds();
    int i = 0;/*from  www.  j a v  a  2s .c  o m*/
    for (Tuple<Set<Parameter<?>>, Set<Parameter<?>>> tuple : ppm.getJoinTuples().get(baseEvent)) {
        final Set<Parameter<?>> compatibleSubset = tuple._1();
        final Set<Parameter<?>> enableSet = tuple._2();
        final int[] nodeMask = toParameterMask(compatibleSubset);
        final int monitorSetId = monitorSetIds.get(compatibleSubset, enableSet);
        final int[] extensionPattern = getExtensionPattern(baseEvent.getParameters(), enableSet);
        final int[] copyPattern = getCopyPattern(baseEvent.getParameters(), enableSet);
        final int[][] disableMasks = toParameterMasks(getDisableSets(ppm, baseEvent, enableSet),
                Sets.union(baseEvent.getParameters(), enableSet));
        result[i++] = new JoinArgs(nodeMask, monitorSetId, extensionPattern, copyPattern, disableMasks);
    }
    return result;
}

From source file:dk.ilios.spanner.benchmark.ParameterSet.java

/**
 * Create the combined set of Parameters set in code in the benchmark class and any potential overrides.
 * NOTE: Overrides not used currently. Legacy from Spanner where commandline params took precedence.
 *///from  ww w  .j a v  a2 s . co  m
public ImmutableSetMultimap<String, String> fillInDefaultsFor(
        ImmutableSetMultimap<String, String> explicitValues) {
    ImmutableSetMultimap.Builder<String, String> combined = ImmutableSetMultimap.builder();

    // For user parameters, this'll actually be the same as fromClass.keySet(), since any extras
    // given at the command line are treated as errors; for VM parameters this is not the case.
    for (String name : Sets.union(map.keySet(), explicitValues.keySet())) {
        Parameter parameter = map.get(name);
        ImmutableCollection<String> values = explicitValues.containsKey(name) ? explicitValues.get(name)
                : parameter.defaults();

        combined.putAll(name, values);
        if (values.isEmpty()) {
            throw new IllegalArgumentException("ERROR: No default value provided for " + name);
        }
    }
    return combined.orderKeysBy(Ordering.natural()).build();
}

From source file:com.facebook.buck.core.build.engine.impl.BuildRulePipelinesRunner.java

/** Gives the factory a way to construct a {@link RunnableWithFuture} to build the given rule. */
public <T extends RulePipelineState> void addRule(SupportsPipelining<T> rule,
        Function<T, RunnableWithFuture<Optional<BuildResult>>> ruleStepRunnerFactory) {
    BuildRulePipelineStage<T> pipelineStage = getPipelineStage(rule);

    SupportsPipelining<T> previousRuleInPipeline = rule.getPreviousRuleInPipeline();
    if (previousRuleInPipeline != null) {
        Preconditions.checkState(/*  w  w w. j a v a  2  s  .  c  o  m*/
                previousRuleInPipeline.getPipelineStateFactory() == rule.getPipelineStateFactory(),
                "To help ensure that rules have pipeline-compatible rule keys, all rules in a pipeline must share a PipelineStateFactory instance.");
        SortedSet<BuildRule> currentDeps = rule.getBuildDeps();
        SortedSet<BuildRule> previousDeps = previousRuleInPipeline.getBuildDeps();
        Preconditions.checkState(currentDeps.contains(previousRuleInPipeline),
                "Each rule in a pipeline must depend on the previous rule in the pipeline.");
        SetView<BuildRule> extraDeps = Sets.difference(currentDeps,
                Sets.union(previousDeps, Collections.singleton(previousRuleInPipeline)));
        Preconditions.checkState(extraDeps.isEmpty(),
                "Each rule in a pipeline cannot depend on rules which are not also dependencies of the previous rule in the pipeline. "
                        + "This ensures that each rule in the pipeline is ready to build as soon as the previous one completes. "
                        + "%s has extra deps <%s>.",
                rule, Joiner.on(", ").join(extraDeps));
        getPipelineStage(previousRuleInPipeline).setNextStage(pipelineStage);
    }

    pipelineStage.setRuleStepRunnerFactory(ruleStepRunnerFactory);
}

From source file:com.cloudera.science.ml.parallel.summary.InternalStats.java

public void merge(InternalStats other, int maxLevels) {
    if (other.internalNumeric != null) {
        internalNumeric().merge(other.internalNumeric);
    } else {//w  w w  .ja  v  a  2 s  .c  o  m
        Map<String, Entry> entries = histogram();
        Map<String, Entry> merged = Maps.newTreeMap();
        Set<String> keys = Sets.newTreeSet(Sets.union(entries.keySet(), other.histogram().keySet()));
        for (String key : keys) {
            Entry e = entries.get(key);
            Entry entry = other.histogram().get(key);
            Entry newEntry = new Entry();
            if (e != null) {
                newEntry.inc(e.getCount());
            }
            if (entry != null) {
                newEntry.inc(entry.getCount());
            }
            merged.put(key, newEntry);
            if (merged.size() == maxLevels) {
                this.trimmed = true;
                break;
            }
        }
        entries.clear();
        entries.putAll(merged);
        if (other.trimmed) {
            this.trimmed = true;
        }
    }
}

From source file:dagger2.internal.codegen.ProvisionBinding.java

@Override
Set<DependencyRequest> implicitDependencies() {
    // Optimization: If we don't need the memberInjectionRequest, don't create more objects.
    if (!memberInjectionRequest().isPresent()) {
        return dependencies();
    } else {/*from   www .java2s . c o  m*/
        // Optimization: Avoid creating an ImmutableSet+Builder just to union two things together.
        return Sets.union(memberInjectionRequest().asSet(), dependencies());
    }
}

From source file:com.addthis.hydra.Main.java

private static void usage() {
    PluginMap pluginMap = PluginRegistry.defaultRegistry().asMap().get("executables");
    Set<String> hardCodedOptions = Sets.newHashSet("validate", "mss");
    String options = Joiner.on(" | ").join(Sets.union(pluginMap.asBiMap().keySet(), hardCodedOptions));
    String usage = "usage: run [ " + options + " ]";
    System.out.println(usage);//from  w w w.j av a 2s .  co  m
}

From source file:com.google.template.soy.shared.internal.TagWhitelist.java

public TagWhitelist withOptionalSafeTags(Collection<? extends OptionalSafeTag> optionalSafeTags) {
    if (optionalSafeTags.isEmpty()) {
        return this;
    }/*from   w  ww.j a v a2s  .  c  o  m*/
    ImmutableSet<String> optionalSafeTagNames = FluentIterable.from(optionalSafeTags)
            .transform(OptionalSafeTag.TO_TAG_NAME).toSet();
    return new TagWhitelist(Sets.union(safeTagNames, optionalSafeTagNames));
}

From source file:com.github.rinde.logistics.pdptw.mas.comm.BlackboardUser.java

@Override
public Set<Parcel> getParcels() {
    return Sets.union(bcModel.get().getUnclaimedParcels(), claimedParcels);
}

From source file:es.usc.citius.hipster.util.graph.HashBasedHipsterGraph.java

@Override
public Iterable<V> vertices() {
    return Sets.union(Sets.union(graphTable.rowKeySet(), graphTable.columnKeySet()), disconnected);
}