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:uk.co.flax.luwak.benchmark.ValidatorResults.java

public void add(Matches<T> matches, String docId, Set<T> expectedMatches) {
    super.add(matches);

    total++;/*from  w  w  w  . j  a  v a2 s .  c  o m*/
    DocumentMatches<T> docMatches = matches.getMatches(docId);
    if (docMatches == null) {
        missingMatches.putAll(docId, expectedMatches);
        return;
    }

    Set<T> actualMatches = Sets.newHashSet(docMatches);
    Sets.SetView<T> extras = Sets.difference(expectedMatches, actualMatches);
    Sets.SetView<T> missing = Sets.difference(actualMatches, expectedMatches);

    if (extras.size() == 0 && missing.size() == 0)
        correctMatches++;
    else {
        missingMatches.putAll(docMatches.getDocId(), missing);
        extraMatches.putAll(docMatches.getDocId(), extras);
    }

}

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:org.cryptomator.frontend.webdav.mount.WindowsDriveLetters.java

public Set<Character> getAvailableDriveLetters() {
    return Sets.difference(A_TO_Z, getOccupiedDriveLetters());
}

From source file:org.graylog2.rest.models.messages.responses.DecorationStats.java

@SuppressWarnings("unused")
@JsonProperty(FIELD_ADDED_FIELDS)/*from w  w w  . j  av a  2s  .  c om*/
public Map<String, Object> addedFields() {
    return Sets.difference(decoratedMessage().keySet(), originalMessage().keySet()).stream()
            .collect(Collectors.toMap(Function.identity(), key -> decoratedMessage().get(key)));
}

From source file:org.onosproject.cluster.ClusterMetadataDiff.java

public ClusterMetadataDiff(ClusterMetadata oldValue, ClusterMetadata newValue) {
    this.oldValue = oldValue;
    this.newValue = newValue;

    Set<ControllerNode> currentNodeSet = oldValue == null ? ImmutableSet.of()
            : ImmutableSet.copyOf(oldValue.getNodes());
    Set<ControllerNode> newNodeSet = newValue == null ? ImmutableSet.of()
            : ImmutableSet.copyOf(newValue.getNodes());
    nodesAdded = Sets.difference(newNodeSet, currentNodeSet);
    nodesRemoved = Sets.difference(currentNodeSet, newNodeSet).stream().map(ControllerNode::id)
            .collect(Collectors.toSet());
}

From source file:org.apache.jackrabbit.oak.plugins.blob.datastore.SharedDataStoreUtils.java

/**
 * Repositories from which marked references not available.
 * //from  ww  w  .  ja v  a  2 s .  com
 * @param repos the repos
 * @param refs the refs
 * @return the sets the sets whose references not available
 */
public static Set<String> refsNotAvailableFromRepos(List<DataRecord> repos, List<DataRecord> refs) {
    return Sets.difference(FluentIterable.from(repos).uniqueIndex(new Function<DataRecord, String>() {
        @Override
        @Nullable
        public String apply(@Nonnull DataRecord input) {
            return SharedStoreRecordType.REPOSITORY.getIdFromName(input.getIdentifier().toString());
        }
    }).keySet(), FluentIterable.from(refs).uniqueIndex(new Function<DataRecord, String>() {
        @Override
        @Nullable
        public String apply(@Nonnull DataRecord input) {
            return SharedStoreRecordType.REFERENCES.getIdFromName(input.getIdentifier().toString());
        }
    }).keySet());
}

From source file:org.obiba.mica.dataset.search.rest.harmonization.ContingencyUtils.java

public static List<String> getValuesHeaders(DatasetVariable variable,
        Mica.DatasetVariableContingenciesDto dto) {
    List<String> values = variable.getCategories() != null
            ? variable.getCategories().stream().map(c -> c.getName()).collect(toList())
            : Lists.newArrayList();/*w  w  w. java 2  s  .c  o m*/
    List<String> dtoValues = Lists.newArrayList(dto.getContingenciesList().stream().map(c -> c.getAll())
            .flatMap(a -> a.getFrequenciesList().stream()).map(f -> f.getValue()).collect(toSet()));
    values.addAll(Sets.difference(Sets.newHashSet(dtoValues), Sets.newHashSet(values)));

    return values;
}

From source file:org.obiba.mica.access.domain.DataAccessRequest.java

@Override
public void setAttachments(List<Attachment> attachments) {
    if (attachments == null)
        attachments = Lists.newArrayList();

    this.removedAttachments = Sets.difference(Sets.newHashSet(this.attachments), Sets.newHashSet(attachments));
    this.attachments = attachments;
}

From source file:com.github.fhirschmann.clozegen.lib.QGapGenerator.java

@Override
public Gap next() {
    Set<String> valid = Sets.newHashSet(someStrings(10));
    Set<String> invalid = Sets.newHashSet(someStrings(10));
    return Gap.with(valid, Sets.difference(invalid, valid));
}

From source file:uk.ac.ebi.atlas.profiles.differential.IsDifferentialProfileSpecific.java

public IsDifferentialProfileSpecific(Set<Contrast> selectedQueryContrasts, Set<Contrast> allQueryFactors) {
    checkArgument(!selectedQueryContrasts.isEmpty(), "selectedQueryContrasts is empty");
    checkArgument(!allQueryFactors.isEmpty(), "allQueryFactors is empty");

    this.selectedQueryContrasts = selectedQueryContrasts;
    this.nonSelectedQueryContrasts = Sets.difference(allQueryFactors, selectedQueryContrasts);
}