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:edu.mit.streamjit.util.bytecode.Access.java
public static Access fromModifiers(Set<Modifier> modifiers) { Set<Modifier> active = Sets.intersection(allAccessModifiers(), modifiers); for (Access a : values()) if (active.equals(a.modifiers())) return a; throw new IllegalArgumentException("bad access modifiers: " + active); }
From source file:de.faustedition.reasoning.InscriptionRelations.java
public static boolean exclusivelyContains(Inscription i, Inscription j) { // i spans j but j is missing from i return i.spans(j) && Sets.intersection(i, j).isEmpty(); }
From source file:grakn.core.server.kb.concept.ConceptUtils.java
/** * @param schemaConcepts entry {@link SchemaConcept} set * @return bottom (most specific) non-meta {@link SchemaConcept}s from within the provided set *///from ww w .j a v a 2s. com public static <T extends SchemaConcept> Set<T> bottom(Set<T> schemaConcepts) { return schemaConcepts.stream() .filter(t -> Sets .intersection(t.subs().filter(t2 -> !t.equals(t2)).collect(toSet()), schemaConcepts) .isEmpty()) .collect(toSet()); }
From source file:es.usc.citius.composit.core.matcher.ExactSetMatchFunction.java
@Override public MatchTable<E, Boolean> fullMatch(Set<E> source, Set<E> target) { Sets.SetView<E> result = Sets.intersection(source, target); MatchTable<E, Boolean> matchTable = new MatchTable<E, Boolean>(); for (E e : result) { matchTable.addMatch(e, e, true); }/*from ww w . ja v a2 s . c o m*/ return matchTable; }
From source file:com.facebook.buck.core.description.arg.CommonDescriptionArg.java
@Value.Derived default boolean labelsContainsAnyOf(Set<String> labels) { return !Sets.intersection(this.getLabels(), labels).isEmpty(); }
From source file:edu.illinois.cs.cogcomp.wikifier.utils.F1Calculator.java
public void addInstances(Set<T> gold, Set<T> answer) { goldCount += gold.size(); answerCount += answer.size(); correctCount += Sets.intersection(gold, answer).size(); }
From source file:org.caleydo.view.relationshipexplorer.ui.util.EntityMappingUtil.java
public static Set<Object> getFilteredElementIDsOf(Set<Object> elementIDs, IEntityCollection collection) { return new HashSet<>(Sets.intersection(collection.getFilteredElementIDs(), elementIDs)); }
From source file:org.jon.ivmark.graphit.core.properties.filter.DisjointFilter.java
@Override public boolean apply(Object property) { if (property == null) { return true; }/*from ww w.j a v a 2s. co m*/ Set<Object> set = Json.OBJECT_MAPPER.convertValue(property, new TypeReference<Set<Object>>() { }); return Sets.intersection(target, set).isEmpty(); }
From source file:org.elasticsearch.cache.recycler.MockPageCacheRecycler.java
public static void ensureAllPagesAreReleased() throws Exception { final Map<Object, Throwable> masterCopy = Maps.newHashMap(ACQUIRED_PAGES); if (!masterCopy.isEmpty()) { // not empty, we might be executing on a shared cluster that keeps on obtaining // and releasing pages, lets make sure that after a reasonable timeout, all master // copy (snapshot) have been released boolean success = ESTestCase.awaitBusy(new Predicate<Object>() { @Override/*from w w w . j av a 2s .c om*/ public boolean apply(Object input) { return Sets.intersection(masterCopy.keySet(), ACQUIRED_PAGES.keySet()).isEmpty(); } }); if (!success) { masterCopy.keySet().retainAll(ACQUIRED_PAGES.keySet()); ACQUIRED_PAGES.keySet().removeAll(masterCopy.keySet()); // remove all existing master copy we will report on if (!masterCopy.isEmpty()) { final Throwable t = masterCopy.entrySet().iterator().next().getValue(); throw new RuntimeException(masterCopy.size() + " pages have not been released", t); } } } }
From source file:com.facebook.buck.apple.FatBinaryInfos.java
/** * Inspect the given build target and return information about it if its a fat binary. * * @return non-empty when the target represents a fat binary. * @throws com.facebook.buck.util.HumanReadableException * when the target is a fat binary but has incompatible flavors. *//*w ww .j a va2 s. co m*/ public static Optional<FatBinaryInfo> create( final Map<Flavor, AppleCxxPlatform> platformFlavorsToAppleCxxPlatforms, BuildTarget target) { ImmutableList<ImmutableSortedSet<Flavor>> thinFlavorSets = generateThinFlavors( platformFlavorsToAppleCxxPlatforms.keySet(), target.getFlavors()); if (thinFlavorSets.size() <= 1) { // Actually a thin binary return Optional.absent(); } if (!Sets.intersection(target.getFlavors(), FORBIDDEN_BUILD_ACTIONS).isEmpty()) { throw new HumanReadableException("%s: Fat binaries is only supported when building an actual binary.", target); } Predicate<Flavor> isPlatformFlavor = Predicates.in(platformFlavorsToAppleCxxPlatforms.keySet()); AppleCxxPlatform representativePlatform = null; AppleSdk sdk = null; for (SortedSet<Flavor> flavorSet : thinFlavorSets) { AppleCxxPlatform platform = Preconditions.checkNotNull( platformFlavorsToAppleCxxPlatforms.get(Iterables.find(flavorSet, isPlatformFlavor))); if (sdk == null) { sdk = platform.getAppleSdk(); representativePlatform = platform; } else if (sdk != platform.getAppleSdk()) { throw new HumanReadableException( "%s: Fat binaries can only be generated from binaries compiled for the same SDK.", target); } } FatBinaryInfo.Builder builder = FatBinaryInfo.builder().setFatTarget(target) .setRepresentativePlatform(Preconditions.checkNotNull(representativePlatform)); BuildTarget platformFreeTarget = target.withoutFlavors(platformFlavorsToAppleCxxPlatforms.keySet()); for (SortedSet<Flavor> flavorSet : thinFlavorSets) { builder.addThinTargets(platformFreeTarget.withFlavors(flavorSet)); } return Optional.of(builder.build()); }