List of usage examples for com.google.common.collect Sets union
public static <E> SetView<E> union(final Set<? extends E> set1, final Set<? extends E> set2)
From source file:com.davidbracewell.math.similarity.AbstractCorrelationSimilarity.java
@Override public double calculate(Map<?, ? extends Number> m1, Map<?, ? extends Number> m2) { Preconditions.checkNotNull(m1, "Vectors cannot be null"); Preconditions.checkNotNull(m2, "Vectors cannot be null"); Index index = Indexes.newIndex(Sets.union(m1.keySet(), m2.keySet())); double[] v1 = new double[index.size()]; double[] v2 = new double[index.size()]; for (int i = 0; i < index.size(); i++) { v1[i] = m1.containsKey(index.get(i)) ? m1.get(index.get(i)).doubleValue() : 0d; v2[i] = m2.containsKey(index.get(i)) ? m2.get(index.get(i)).doubleValue() : 0d; }//from ww w . j av a 2 s . co m return calculate(v1, v2); }
From source file:com.willowtreeapps.saguaro.plugin.SaguaroGenerate.java
private Set<LicenseDependency> collectLicenses(SaguaroConfig config) throws PluginException { return Sets.union(collectDefinedLicenses(config), collectDependencyLicences(config)); }
From source file:org.gradle.language.base.internal.tasks.apigen.abi.DefaultApiValidator.java
@Override public <T> T validateMethod(MethodSig methodSig, Factory<T> onValidate) { Set<String> invalidReferencedTypes = invalidReferencedTypes( methodSig.getSignature() == null ? methodSig.getDesc() : methodSig.getSignature()); for (String exception : methodSig.getExceptions()) { invalidReferencedTypes = Sets.union(invalidReferencedTypes, invalidReferencedTypes(exception)); }//from w ww . j av a 2 s. c o m if (invalidReferencedTypes.isEmpty()) { return onValidate.create(); } if (invalidReferencedTypes.size() == 1) { throw new InvalidPublicAPIException(String.format( "In %s, type %s is exposed in the public API but its package is not one of the allowed packages.", methodSig, invalidReferencedTypes.iterator().next())); } else { StringBuilder sb = new StringBuilder("The following types are referenced in "); sb.append(methodSig); sb.append(" but their package is not one of the allowed packages:\n"); for (String invalidReferencedType : invalidReferencedTypes) { sb.append(" - ").append(invalidReferencedType).append("\n"); } throw new InvalidPublicAPIException(sb.toString()); } }
From source file:org.geoserver.geopkg.GeoPackageGetFeatureOutputFormat.java
public GeoPackageGetFeatureOutputFormat(GeoServer gs) { super(gs, Sets.union(Sets.newHashSet(MIME_TYPE), Sets.newHashSet(NAMES))); }
From source file:org.gradle.api.internal.attributes.DefaultMutableAttributeContainer.java
@Override public Set<Attribute<?>> keySet() { if (parent == null) { return state.keySet(); } else {/* w w w .j av a2 s . c o m*/ return Sets.union(parent.keySet(), state.keySet()); } }
From source file:org.sosy_lab.cpachecker.cfa.ast.c.FileLocationCollectingVisitor.java
@Override public Set<FileLocation> visit(CBinaryExpression pE) throws RuntimeException { return Sets.union(Collections.singleton(pE.getFileLocation()), Sets.union(pE.getOperand1().accept(this), pE.getOperand2().accept(this))); }
From source file:com.jgaap.distances.NominalKSDistance.java
/** * Calculate the Kolmogorov-Smirnov distance between two event sets. * @return The nominal KS distance between two event sets. *//*from w w w . j av a 2 s. c o m*/ @Override public double distance(Histogram unknownHistogram, Histogram knownHistogram) { double distance = 0.0; Set<Event> events = Sets.union(unknownHistogram.uniqueEvents(), knownHistogram.uniqueEvents()); for (Event event : events) { distance += Math .abs(unknownHistogram.relativeFrequency(event) - knownHistogram.relativeFrequency(event)); } return (1.0 / 2.0) * distance; }
From source file:de.bund.bfr.jung.BetterDirectedSparseMultigraph.java
@Override public Collection<V> getVertices() { Set<V> picked = owner.getPickedVertexState().getPicked(); Set<V> unPicked = Sets.difference(vertices.keySet(), picked); return Sets.union(unPicked, picked); }
From source file:prm4j.indexing.model.FindMaxArgs.java
public static List<Set<Parameter<?>>> getDisableSets(ParametricPropertyModel ppa, BaseEvent baseEvent, final Set<Parameter<?>> enableSet) { final Set<Parameter<?>> combination = Sets.union(baseEvent.getParameters(), enableSet); return toListOfParameterSetsAscending( Sets.filter(toParameterSets(ppa.getParametricProperty().getSpec().getBaseEvents()), new Predicate<Set<Parameter<?>>>() { @Override public boolean apply(Set<Parameter<?>> baseEventParameterSet) { return combination.containsAll(baseEventParameterSet) && !enableSet.containsAll(baseEventParameterSet); }//from ww w. j ava 2s .co m })); }
From source file:org.sosy_lab.cpachecker.cfa.ast.c.CIdExpressionCollectingVisitor.java
@Override public Set<CIdExpression> visit(CBinaryExpression pE) throws RuntimeException { return Sets.union(pE.getOperand1().accept(this), pE.getOperand2().accept(this)); }