List of usage examples for com.google.common.collect Sets difference
public static <E> SetView<E> difference(final Set<E> set1, final Set<?> set2)
From source file:edu.buaa.satla.analysis.cfa.CFACheck.java
/** * Traverse the CFA and run a series of checks at each node * @param cfa Node to start traversal from * @param nodes Optional set of all nodes in the CFA (may be null) * @param pruned Whether the CFA was pruned and may be incomplete. *//* w w w . j a va 2 s . c om*/ public static boolean check(FunctionEntryNode cfa, Collection<CFANode> nodes, boolean pruned) { Set<CFANode> visitedNodes = new HashSet<>(); Deque<CFANode> waitingNodeList = new ArrayDeque<>(); waitingNodeList.add(cfa); while (!waitingNodeList.isEmpty()) { CFANode node = waitingNodeList.poll(); if (visitedNodes.add(node)) { Iterables.addAll(waitingNodeList, CFAUtils.successorsOf(node)); Iterables.addAll(waitingNodeList, CFAUtils.predecessorsOf(node)); // just to be sure to get ALL nodes. // The actual checks isConsistent(node); checkEdgeCount(node, pruned); } } if (nodes != null) { if (!visitedNodes.equals(nodes)) { assert false : "\nNodes in CFA but not reachable through traversal: " + Iterables.transform(Sets.difference(new HashSet<>(nodes), visitedNodes), DEBUG_FORMAT) + "\nNodes reached that are not in CFA: " + Iterables.transform(Sets.difference(visitedNodes, new HashSet<>(nodes)), DEBUG_FORMAT); } } return true; }
From source file:org.wso2.carbon.governance.comparator.wsdl.WSDLPortTypeComparator.java
protected void comparePortTypes(Definition base, Definition changed, DefaultComparison comparison) { //Here we only compare additions and removals only. DefaultComparison.DefaultSection section = null; Set<QName> basePortTypeNames = base.getPortTypes().keySet(); Set<QName> ChangedPortTypeNames = changed.getPortTypes().keySet(); Set<QName> additionKeys = Sets.difference(ChangedPortTypeNames, basePortTypeNames); if (section == null && additionKeys.size() > 0) { section = comparison.newSection(); }//w w w. j av a 2 s . c om processAdditions(section, additionKeys, changed); Set<QName> removalKeys = Sets.difference(basePortTypeNames, ChangedPortTypeNames); if (section == null && removalKeys.size() > 0) { section = comparison.newSection(); } processRemovals(section, removalKeys, base); if (section != null) { comparison.addSection(ComparatorConstants.WSDL_IMPORTS, section); } }
From source file:com.facebook.buck.rules.coercer.StringWithMacrosTypeCoercer.java
private StringWithMacrosTypeCoercer(ImmutableMap<String, Class<? extends Macro>> macros, ImmutableMap<Class<? extends Macro>, MacroTypeCoercer<? extends Macro>> coercers) { Preconditions.checkArgument(Sets.difference(coercers.keySet(), new HashSet<>(macros.values())).isEmpty()); this.macros = macros; this.coercers = coercers; }
From source file:com.google.devtools.build.docgen.MultiPageBuildEncyclopediaProcessor.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 w ww. j a va 2 s. c om @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(), false); Map<String, RuleDocumentation> ruleDocEntries = collector.collect(inputDirs, blackList, expander); warnAboutUndocumentedRules( Sets.difference(ruleClassProvider.getRuleClassMap().keySet(), ruleDocEntries.keySet())); writeStaticDoc(outputDir, expander, "make-variables"); writeStaticDoc(outputDir, expander, "predefined-python-variables"); writeStaticDoc(outputDir, expander, "functions"); writeCommonDefinitionsPage(outputDir, expander); writeRuleDocs(outputDir, expander, ruleDocEntries.values()); }
From source file:org.apache.fluo.core.observer.v2.ObserversV2.java
public ObserversV2(Environment env, JsonObservers jco, Set<Column> strongColumns, Set<Column> weakColumns) { ObserverProvider obsProvider = ObserverStoreV2.newObserverProvider(jco.getObserverProviderClass()); ObserverProviderContextImpl ctx = new ObserverProviderContextImpl(env); ObserverRegistry or = new ObserverRegistry(strongColumns, weakColumns); obsProvider.provide(or, ctx);/*from www . jav a 2 s .co m*/ this.observers = or.observers; this.aliases = or.aliases; this.observers.forEach((k, v) -> aliases.computeIfAbsent(k, col -> Hex.encNonAscii(col, ":"))); // the following check ensures observers are provided for all previously configured columns SetView<Column> diff = Sets.difference(observers.keySet(), Sets.union(strongColumns, weakColumns)); if (diff.size() > 0) { throw new FluoException("ObserverProvider " + jco.getObserverProviderClass() + " did not provide observers for columns " + diff); } }
From source file:org.onosproject.store.resource.impl.GenericDiscreteResources.java
@Override public DiscreteResources difference(DiscreteResources other) { if (other instanceof GenericDiscreteResources) { // make sure that the set is serializable return of(new LinkedHashSet<>(Sets.difference(this.values(), other.values()))); } else if (other instanceof EmptyDiscreteResources) { return this; }//from w w w . j av a 2 s .c o m return DiscreteResources.of(Sets.difference(this.values(), other.values())); }
From source file:eu.lp0.cursus.ui.table.RaceNumbersDatabaseColumnModel.java
private Iterable<RaceNumber> getRaceNumberList(Pilot row) { if (row.getRaceNumber() == null) { return Ordering.natural().sortedCopy(row.getRaceNumbers()); } else {// www .ja v a2s . com return Iterables.concat(Collections.singletonList(row.getRaceNumber()), Ordering.natural() .sortedCopy(Sets.difference(row.getRaceNumbers(), Collections.singleton(row.getRaceNumber())))); } }
From source file:nz.co.testamation.testcommon.fixture.SomeFixture.java
public static <T extends Enum> T someEnumOtherThan(Class<T> enumClazz, T... excluded) { return someValue( Sets.difference(ImmutableSet.copyOf(enumClazz.getEnumConstants()), ImmutableSet.copyOf(excluded))); }
From source file:edu.harvard.med.screensaver.model.libraries.PlateStatus.java
private static Set<PlateStatus> allExcept(Set<PlateStatus> invalidPlateStatuses) { return Sets.difference(ImmutableSet.of(PlateStatus.values()), invalidPlateStatuses); }
From source file:org.gradle.api.internal.tasks.compile.incremental.jar.PreviousCompilation.java
public DependentsSet getDependents(String className, Set<Integer> newConstants) { Set<Integer> constants = Sets.difference(analysis.getData().getConstants(className), newConstants); return analysis.getRelevantDependents(className, constants); }