List of usage examples for com.google.common.collect Sets newIdentityHashSet
public static <E> Set<E> newIdentityHashSet()
From source file:org.sosy_lab.cpachecker.cpa.value.refiner.ValueAnalysisRefiner.java
/** * Merge all predicate precisions in the subgraph below the refinement root * into a new predicate precision/*from w w w.j av a2 s . c o m*/ * * @return a new predicate precision containing all predicate precision from * the subgraph below the refinement root. */ private PredicatePrecision mergePredictePrecisionsForSubgraph(final ARGState pRefinementRoot, final ARGReachedSet pReached) { PredicatePrecision mergedPrecision = PredicatePrecision.empty(); // find all distinct precisions to merge them Set<PredicatePrecision> uniquePrecisions = Sets.newIdentityHashSet(); for (ARGState descendant : getNonCoveredStatesInSubgraph(pRefinementRoot)) { uniquePrecisions.add(extractPredicatePrecision(pReached, descendant)); } for (PredicatePrecision precision : uniquePrecisions) { mergedPrecision = mergedPrecision.mergeWith(precision); } return mergedPrecision; }
From source file:org.cloudsmith.geppetto.validation.impl.ValidationServiceImpl.java
/** * @param moduleData/*from w w w. j a v a 2 s . c o m*/ * - resolved module data * @param root * - root file for relativization * @param diagnostics * - where to report issues */ private void checkCircularDependencies(Multimap<ModuleName, MetadataInfo> moduleData, Diagnostic diagnostics, File root) { // problems: multiple versions of the same, etc.Use an identity set for (MetadataInfo mi : moduleData.values()) { Set<MetadataInfo> checkedModules = Sets.newIdentityHashSet(); List<MetadataInfo> circle = Lists.newLinkedList(); checkCircularity(mi, mi, circle, checkedModules); } }
From source file:com.atlassian.jira.ComponentManager.java
private void registerEventComponents() { EventPublisher eventPublisher = getComponent(EventPublisher.class); Set<Object> registeredListeners = Sets.newIdentityHashSet(); Collection<ComponentAdapter<?>> componentAdapters = getContainer().getComponentAdapters(); for (ComponentAdapter<?> componentAdapter : componentAdapters) { Class<?> componentKey = componentAdapter.getComponentImplementation(); if (componentKey.getAnnotation(EventComponent.class) != null) { Object instance = componentAdapter.getComponentInstance(container.getPicoContainer(), ComponentAdapter.NOTHING.class); if (registeredListeners.add(instance)) { eventPublisher.register(instance); }/*from w w w .j a v a 2s . co m*/ } } }
From source file:com.streamsets.datacollector.execution.runner.common.ProductionPipelineRunner.java
private void errorNotification(Pipe[] pipes, Throwable throwable) throws StageException { Set<ErrorListener> listeners = Sets.newIdentityHashSet(); for (Pipe pipe : pipes) { Stage stage = pipe.getStage().getStage(); if (stage instanceof ErrorListener) { listeners.add((ErrorListener) stage); }//w w w .j av a 2s.c o m } for (ErrorListener listener : listeners) { try { listener.errorNotification(throwable); } catch (Exception ex) { String msg = Utils.format("Error in calling ErrorListenerStage {}: {}", listener.getClass().getName(), ex); LOG.error(msg, ex); } } }
From source file:org.jamocha.dn.compiler.ecblocks.Block.java
@SuppressWarnings("checkstyle:methodlength") public boolean isConsistentBlock() { /*//from ww w .j av a 2 s . c o m A non-empty subset $Z\subset E(G)$ of the edges of the assignment graph $G$ is called a \emph{block row} if the following conditions are fulfilled: \begin{itemize} \item If an edge adjacent to a filter is in $Z$, all edges in $G$ adjacent to that filter have to be in $Z$. \item The edge to a non-implicit occurrence is in $Z$ iff at least one edge from that occurrence to a binding is in $Z$. \item The edge from a fact or slot binding to the corresponding template INSTANCE is in $Z$ iff at least one edge from an occurrence to that binding is in $Z$. \item If an edge from a binding to a template INSTANCE is in $Z$, all edges in $G$ adjacent to that template INSTANCE have to be in $Z$. \item If an edge from an occurrence to a functional expression binding is in $Z$, all edges originating from that binding have to be in $Z$. \item If an edge from a functional expression binding is in $Z$, at least one edge to that binding has to be in $Z$. \item An edge from an implicit occurrence to its corresponding binding is in $Z$ iff at least one other edge to that binding is in $Z$. \item If the edges $(o,b)$, $(o,b')$, and $(o',b)$ for occurrences $o$, $o'$ and bindings $b$, $b'$ are in $Z$, then $(o',b')$ has to be in $Z$. \item For all occurrences in functional expressions with adjacent edges in $Z$, it holds that there are paths in $Z$ from these occurrences to slot, fact, or constant bindings. \item If an existential edge $(f,o)$ adjacent to a filter $f$ is in $Z$, the connected component originating from removing all existential edges adjacent to $f$ that contains $o$ has to be a subset of $Z$. \end{itemize} */ final RowContainer rowContainer = this.rowContainer; final Set<BindingNode> bindingNodes = rowContainer.getRows().stream() .map(AssignmentGraph.UnrestrictedGraph.SubGraph::getBindingNodes).flatMap(Set::stream) .collect(toIdentityHashSet()); final Set<ECOccurrenceNode> occurrenceNodes = rowContainer.getRows().stream() .map(AssignmentGraph.UnrestrictedGraph.SubGraph::getECOccurrenceNodes).flatMap(Set::stream) .collect(toIdentityHashSet()); final Set<FilterOccurrenceNode> filterOccurrenceNodes = Sets.newIdentityHashSet(); final Set<FunctionalExpressionOccurrenceNode> functionalExpressionOccurrenceNodes = Sets .newIdentityHashSet(); final Set<ImplicitOccurrenceNode> implicitOccurrenceNodes = Sets.newIdentityHashSet(); final Set<ConstantBindingNode> constantBindingNodes = Sets.newIdentityHashSet(); final Set<SlotOrFactBindingNode> slotOrFactBindingNodes = Sets.newIdentityHashSet(); final Set<FunctionalExpressionBindingNode> functionalExpressionBindingNodes = Sets.newIdentityHashSet(); for (final BindingNode bindingNode : bindingNodes) { if (rowContainer.getRow(bindingNode).incomingEdgesOf(bindingNode).isEmpty()) { throw new IllegalNodeDegreeException("A binding node without incoming edges has been detected!"); } switch (bindingNode.getNodeType()) { case SLOT_OR_FACT_BINDING: slotOrFactBindingNodes.add((SlotOrFactBindingNode) bindingNode); break; case CONSTANT_EXPRESSION: constantBindingNodes.add((ConstantBindingNode) bindingNode); break; case FUNCTIONAL_EXPRESSION: functionalExpressionBindingNodes.add((FunctionalExpressionBindingNode) bindingNode); break; } } for (final ECOccurrenceNode occurrenceNode : occurrenceNodes) { if (rowContainer.getRow(occurrenceNode).outgoingEdgesOf(occurrenceNode).isEmpty()) { throw new IllegalNodeDegreeException( "An occurrence node without outgoing edges has been detected!"); } switch (occurrenceNode.getNodeType()) { case IMPLICIT_OCCURRENCE: implicitOccurrenceNodes.add((ImplicitOccurrenceNode) occurrenceNode); break; case FILTER_OCCURRENCE: filterOccurrenceNodes.add((FilterOccurrenceNode) occurrenceNode); break; case FUNCTIONAL_OCCURRENCE: functionalExpressionOccurrenceNodes.add((FunctionalExpressionOccurrenceNode) occurrenceNode); break; } } // now all occurrence nodes have outgoing edges // all bindings nodes have incoming edges { // If an edge adjacent to a filter is in $Z$, all edges in $G$ adjacent to that filter have to be in $Z$. final Map<ECFilter, Set<FilterOccurrenceNode>> filterToOccurrences = filterOccurrenceNodes.stream() .collect(groupingBy(FilterOccurrenceNode::getFilter, toSet())); for (final Map.Entry<ECFilter, Set<FilterOccurrenceNode>> filterAndOccurrences : filterToOccurrences .entrySet()) { final ECFilter filter = filterAndOccurrences.getKey(); final Set<FilterOccurrenceNode> occurrences = filterAndOccurrences.getValue(); final Collection<FilterOccurrenceNode> arguments = this.graph.getFilterToOccurrenceNodes() .get(filter).values(); if (!occurrences.containsAll(arguments)) { throw new FaultyArgumentBindingException("Not all arguments of a filter are bound!"); } } } // The edge to a non-implicit occurrence is in $Z$ iff at least one edge from that occurrence to a binding is // in $Z$. // => we already checked that there is at least one outgoing edge for every occurrence { // The edge from a fact or slot binding to the corresponding template INSTANCE is in $Z$ iff at least one // edge from an occurrence to a binding of this template INSTANCE is in $Z$. // => graph will not contain unused bindings, but the set of fact variables used (stored in the block // class) // has to be identical to the set of fact variables used in the graph via edges final Set<SingleFactVariable> factVariables = slotOrFactBindingNodes.stream() .map(SlotOrFactBindingNode::getGroupingFactVariable).collect(toIdentityHashSet()); if (!this.factVariablesUsed.equals(factVariables)) { throw new InconsistentTemplateInstanceSetException( "Template instance set of the block differs from that of the rows!"); } } { // If an edge from an occurrence to a functional expression binding is in $Z$, all edges originating from // that binding have to be in $Z$. // If an edge from a functional expression binding is in $Z$, at least one edge to that binding has to be // in $Z$. final Map<FunctionalExpressionBindingNode, Set<FunctionalExpressionOccurrenceNode>> feToOccurrences = functionalExpressionOccurrenceNodes .stream() .collect(groupingBy(FunctionalExpressionOccurrenceNode::getGroupingBindingNode, toSet())); for (final Map.Entry<FunctionalExpressionBindingNode, Set<FunctionalExpressionOccurrenceNode>> feAndOccurrences : feToOccurrences .entrySet()) { final FunctionalExpressionBindingNode functionalExpressionBindingNode = feAndOccurrences.getKey(); if (!functionalExpressionBindingNodes.contains(functionalExpressionBindingNode)) { throw new FaultyArgumentBindingException( "Arguments of an unused functional expression are " + "bound!"); } final Set<FunctionalExpressionOccurrenceNode> occurrences = feAndOccurrences.getValue(); final Collection<FunctionalExpressionOccurrenceNode> arguments = this.graph .getFunctionalExpressionBindingToOccurrenceNodes().get(functionalExpressionBindingNode) .values(); if (!occurrences.containsAll(arguments)) { throw new FaultyArgumentBindingException( "Not all arguments of a functional expression are " + "bound!"); } } } { // An edge from an implicit occurrence to its corresponding binding is in $Z$ iff at least one other edge // to that binding is in $Z$. for (final BindingNode binding : bindingNodes) { final ImplicitOccurrenceNode implicitOccurrenceNode = this.graph .getBindingNodeToImplicitOccurrence().get(binding); final AssignmentGraph.UnrestrictedGraph.SubGraph row = rowContainer.getRow(binding); if (row.inDegreeOf(binding) > 1 ^ !row.containsEdge(implicitOccurrenceNode, binding)) { throw new IllegalUseOfImplicitOccurrenceException( "Edge to implicit occurrence is contained, but no other edge to that binding!"); } } } { // If the edges $(o,b)$, $(o,b')$, and $(o',b)$ for occurrences $o$, $o'$ and bindings $b$, $b'$ are in // $Z$, then $(o',b')$ has to be in $Z$. // we will always fix (o,b) to be the edge to the binding from its corresponding occurrence // then look for other edges to that binding and inspect their occurrence nodes // then look for other edges from these occurrence nodes to other bindings // if there is such a chain of edges, there has to be an edge from the original occurrence to each of the // latter bindings for (final BindingNode binding : bindingNodes) { final AssignmentGraph.UnrestrictedGraph.SubGraph row = rowContainer.getRow(binding); final Set<Edge<ECOccurrenceNode, BindingNode>> edgesToBinding = row.incomingEdgesOf(binding); if (edgesToBinding.size() < 2) continue; final ImplicitOccurrenceNode correspondingOccurrenceNode = this.graph .getBindingNodeToImplicitOccurrence().get(binding); final Edge<ECOccurrenceNode, BindingNode> correspondingEdge = row .getEdge(correspondingOccurrenceNode, binding); for (final Edge<ECOccurrenceNode, BindingNode> otherEdgeToBinding : edgesToBinding) { if (otherEdgeToBinding == correspondingEdge) { continue; } final ECOccurrenceNode otherOccurrence = otherEdgeToBinding.getSource(); final Set<Edge<ECOccurrenceNode, BindingNode>> outgoingEdgesOfOtherOccurrence = row .outgoingEdgesOf(otherOccurrence); if (outgoingEdgesOfOtherOccurrence.size() < 2) { continue; } for (final Edge<ECOccurrenceNode, BindingNode> outgoingEdgeOfOtherOccurrence : outgoingEdgesOfOtherOccurrence) { if (outgoingEdgeOfOtherOccurrence == otherEdgeToBinding) { continue; } final BindingNode otherBinding = outgoingEdgeOfOtherOccurrence.getTarget(); if (!row.containsEdge(correspondingOccurrenceNode, otherBinding)) { throw new NoStronglyConnectedSubsetException( "An edge is missing for a strongly connected equivalence class subset!"); } } } } } { // For all occurrences in functional expressions with adjacent edges in $Z$, it holds that there are paths // in $Z$ from these occurrences to slot, fact, or constant bindings. if (!FunctionalExpressionBindingChecker.check(this.graph, rowContainer, functionalExpressionBindingNodes)) { throw new NoPathToDirectBindingException( "No edge from a functional expression occurrence to a slot, fact, or constant binding!"); } } { // If an existential edge $(f,o)$ adjacent to a filter $f$ is in $Z$, the connected component originating // from removing all existential edges adjacent to $f$ that contains $o$ has to be a subset of $Z$. final Map<ECFilter, ExistentialInfo> existentialFilters = filterOccurrenceNodes.stream() .filter(node -> node.getFunctionWithExistentialInfo().getExistentialInfo().isExistential()) .collect(groupingBy(FilterOccurrenceNode::getFilter, collectingAndThen( mapping(node -> node.getFunctionWithExistentialInfo().getExistentialInfo(), toIdentityHashSet()), set -> set.iterator().next()))); for (final Map.Entry<ECFilter, ExistentialInfo> filterWithExistentialInfo : existentialFilters .entrySet()) { final ExistentialInfo existentialInfo = filterWithExistentialInfo.getValue(); final ECFilter filter = filterWithExistentialInfo.getKey(); for (final AssignmentGraph.UnrestrictedGraph.SubGraph row : rowContainer.getRows()) { if (!ExistentialSubgraphCompletelyContainedChecker.check(this.graph, row, filter, existentialInfo)) { throw new ExistentialSubgraphNotContainedException( "Existential subgraph not completely contained!"); } } } } // Two block rows are \emph{compatible} iff both block rows are disjoint and no edge in the one block row is // adjacent to an edge in the other block row. if (this.rowContainer.getRowCount() != rowContainer.getRows().stream() .mapToInt(row -> ConnectedComponentCounter.countConnectedComponents(this.graph, row)).count()) { throw new IllegalStateException( "The cached number of connected components in the row-subgraph of a block is incorrect!"); } /* A non-empty subset $S\subset E(G)$ of the edges of the assignment graph $G$ is called a \emph{block column} if the following conditions are fulfilled: \begin{itemize} \item All edges in $S$ are pairwise non-adjacent \item For the set of start or target nodes $V'$ of the edges in $S$ one of the following conditions holds: \begin{itemize} \item $V'$ contains filters only and they all apply the same predicate having the same parameters marked as (negated) existential \item $V'$ only contains implicit occurrences \item $V'$ only contains non-implicit occurrences representing the same position in the list of parameters of a filter or functional expression. \item $V'$ only contains bindings to the same constant. \item $V'$ only contains bindings to slots of the same name. The equality of the template is assured via the compatibility of block columns (see below). \item $V'$ only contains fact bindings. \item $V'$ only contains bindings to functional expressions and they all use the same function. \item $V'$ only contains template instances (facts) of the same template. \end{itemize} \item If all start nodes of the edges in $S$ are implicit occurrences, either all or none of the edges lead to the corresponding binding. \end{itemize} */ for (final Column<ECOccurrenceNode, BindingNode> column : this.columns) { // All edges in $S$ are pairwise non-adjacent final int edgeCount = column.getEdges().size(); if (0 == edgeCount) { throw new InconsistentBlockColumnException("A block column is empty!"); } final Set<ECOccurrenceNode> sourceNodes = column.getSourceNodeSet(); if (edgeCount != sourceNodes.size()) { throw new InconsistentBlockColumnException("Edges in block column overlap in source node!"); } final OccurrenceType columnOccurrenceType = column.getOccurrenceType(); if (sourceNodes.stream().map(ECOccurrenceNode::getNodeType) .anyMatch(type -> type != columnOccurrenceType)) { throw new InconsistentBlockColumnException( "Not all of the source nodes of a block column are of the correct type!"); } final Set<BindingNode> targetNodes = column.getTargetNodeSet(); if (edgeCount != targetNodes.size()) { throw new InconsistentBlockColumnException("Edges in block column overlap in target node!"); } final BindingType columnBindingType = column.getBindingType(); if (targetNodes.stream().map(BindingNode::getNodeType).anyMatch(type -> type != columnBindingType)) { throw new InconsistentBlockColumnException( "Not all of the target nodes of a block column are of the correct type!"); } switch (columnOccurrenceType) { case IMPLICIT_OCCURRENCE: // $V'$ only contains implicit occurrences // => check // If all start nodes of the edges in $S$ are implicit occurrences, either all or none of the // edges lead to the corresponding binding. if (1L != column.getEdges().stream().map(edge -> ((ImplicitOccurrenceNode) edge.getSource()) .getCorrespondingBindingNode() == edge.getTarget()).distinct().count()) { throw new InconsistentBlockColumnException( "In a column with implicit occurrences, some of the edges lead to their " + "corresponding binding and others don't!"); } break; case FILTER_OCCURRENCE: { // $V'$ contains filters only and they all apply the same predicate having the same parameters // marked as (negated) existential final Set<FilterOccurrenceNode> occurrences = sourceNodes.stream() .map(node -> (FilterOccurrenceNode) node).collect(toIdentityHashSet()); if (1L != occurrences.stream().map(FilterOccurrenceNode::getFunctionWithExistentialInfo).distinct() .count()) { throw new InconsistentBlockColumnException("Predicates in a block column differ!"); } // $V'$ only contains non-implicit occurrences representing the same position in the list of // parameters of a filter or functional expression. if (1L != occurrences.stream().mapToInt(FilterOccurrenceNode::getParameterPosition).distinct() .count()) { throw new InconsistentBlockColumnException( "Filter occurrences in a block column represent different parameter positions of a " + "filter!"); } } break; case FUNCTIONAL_OCCURRENCE: { // $V'$ only contains non-implicit occurrences representing the same position in the list of // parameters of a filter or functional expression. if (1L != sourceNodes.stream() .mapToInt(node -> ((FunctionalExpressionOccurrenceNode) node).getParameterPosition()) .distinct().count()) { throw new InconsistentBlockColumnException( "Filter occurrences in a block column represent different parameter positions of a " + "filter!"); } } break; } switch (columnBindingType) { case SLOT_OR_FACT_BINDING: { // $V'$ only contains fact bindings. // => check // $V'$ only contains template instances (facts) of the same template. // or // $V'$ only contains bindings to slots of the same name. The equality of the template is assured // via the compatibility of block columns (see below). if (1L != targetNodes.stream().map(node -> ((SlotOrFactBindingNode) node).getSchema()).distinct() .count()) { throw new InconsistentBlockColumnException("Slot of fact bindings in a block column differ!"); } } break; case CONSTANT_EXPRESSION: // $V'$ only contains bindings to the same constant. if (1L != targetNodes.stream().map(node -> ((ConstantBindingNode) node).getConstant()).distinct() .count()) { throw new InconsistentBlockColumnException("Constants in a block column differ!"); } break; case FUNCTIONAL_EXPRESSION: { // $V'$ only contains bindings to functional expressions and they all use the same function. if (1L != targetNodes.stream().map(node -> ((FunctionalExpressionBindingNode) node).getFunction()) .distinct().count()) { throw new InconsistentBlockColumnException("Functions in a block column differ!"); } } break; } } // Two different block columns $S$ and $S'$ are \emph{compatible} iff at most one pair of the sets of start and // target nodes of $S$ and the sets of start and target nodes of $S'$ are identical and all others are // disjoint. { final ICombinatoricsVector<Column<ECOccurrenceNode, BindingNode>> columnVector = Factory .createVector(this.columns); final Generator<Column<ECOccurrenceNode, BindingNode>> generator = Factory .createSimpleCombinationGenerator(columnVector, 2); for (final ICombinatoricsVector<Column<ECOccurrenceNode, BindingNode>> combination : generator) { final Column<ECOccurrenceNode, BindingNode> c0 = combination.getValue(0); final Column<ECOccurrenceNode, BindingNode> c1 = combination.getValue(1); final BindingType bt0 = c0.getBindingType(); final BindingType bt1 = c1.getBindingType(); final Set<BindingNode> b0 = c0.getEdges().stream().map(Edge::getTarget) .collect(toIdentityHashSet()); final Set<BindingNode> b1 = c1.getEdges().stream().map(Edge::getTarget) .collect(toIdentityHashSet()); if (!b0.equals(b1)) { if (!Collections.disjoint(b0, b1)) { throw new IncompatibleColumnsException("There are incompatible columns in the block!"); } if (bt0 == BindingType.SLOT_OR_FACT_BINDING && bt1 == BindingType.SLOT_OR_FACT_BINDING) { final Set<SingleFactVariable> t0 = b0.stream() .map(node -> ((SlotOrFactBindingNode) node).getGroupingFactVariable()) .collect(toIdentityHashSet()); final Set<SingleFactVariable> t1 = b1.stream() .map(node -> ((SlotOrFactBindingNode) node).getGroupingFactVariable()) .collect(toIdentityHashSet()); if (!t0.equals(t1) && !Collections.disjoint(t0, t1)) { throw new IncompatibleColumnsException("There are incompatible columns in the block!"); } } } final OccurrenceType ot0 = c0.getOccurrenceType(); final OccurrenceType ot1 = c1.getOccurrenceType(); final Set<ECOccurrenceNode> o0 = c0.getEdges().stream().map(Edge::getSource) .collect(toIdentityHashSet()); final Set<ECOccurrenceNode> o1 = c1.getEdges().stream().map(Edge::getSource) .collect(toIdentityHashSet()); if (!o0.equals(o1)) { if (!Collections.disjoint(o0, o1)) { throw new IncompatibleColumnsException("There are incompatible columns in the block!"); } if (ot0 == OccurrenceType.FILTER_OCCURRENCE && ot1 == OccurrenceType.FILTER_OCCURRENCE) { final Set<ECFilter> f0 = o0.stream().map(node -> ((FilterOccurrenceNode) node).getFilter()) .collect(toIdentityHashSet()); final Set<ECFilter> f1 = o1.stream().map(node -> ((FilterOccurrenceNode) node).getFilter()) .collect(toIdentityHashSet()); if (!f0.equals(f1) && !Collections.disjoint(f0, f1)) { throw new IncompatibleColumnsException("There are incompatible columns in the block!"); } } if (ot0 == OccurrenceType.FUNCTIONAL_OCCURRENCE && ot1 == OccurrenceType.FUNCTIONAL_OCCURRENCE) { final Set<FunctionalExpressionBindingNode> fe0 = o0.stream() .map(node -> ((FunctionalExpressionOccurrenceNode) node).getGroupingBindingNode()) .collect(toIdentityHashSet()); final Set<FunctionalExpressionBindingNode> fe1 = o1.stream() .map(node -> ((FunctionalExpressionOccurrenceNode) node).getGroupingBindingNode()) .collect(toIdentityHashSet()); if (!fe0.equals(fe1) && !Collections.disjoint(fe0, fe1)) { throw new IncompatibleColumnsException("There are incompatible columns in the block!"); } } } if (bt0 == BindingType.FUNCTIONAL_EXPRESSION && ot1 == OccurrenceType.FUNCTIONAL_OCCURRENCE) { final Set<FunctionalExpressionBindingNode> gb1 = o1.stream() .map(node -> ((FunctionalExpressionOccurrenceNode) node).getGroupingBindingNode()) .collect(toIdentityHashSet()); if (!b0.equals(gb1) && !Collections.disjoint(b0, gb1)) { throw new IncompatibleColumnsException("There are incompatible columns in the block!"); } } if (bt1 == BindingType.FUNCTIONAL_EXPRESSION && ot0 == OccurrenceType.FUNCTIONAL_OCCURRENCE) { final Set<FunctionalExpressionBindingNode> gb0 = o0.stream() .map(node -> ((FunctionalExpressionOccurrenceNode) node).getGroupingBindingNode()) .collect(toIdentityHashSet()); if (!b1.equals(gb0) && !Collections.disjoint(b1, gb0)) { throw new IncompatibleColumnsException("There are incompatible columns in the block!"); } } } } /* We also refer to the number of the elements of a block column as the height of the block column. A set of pairwise compatible block rows $\mathcal{Z}$ together with a set of pairwise compatible block columns $\mathcal{S}$ is called a \emph{block} iff the set of all edges of the block rows is identical to the set of all edges of the block columns and the amount of block rows corresponds to the height of the block columns. */ { if (1L != this.columns.stream().mapToInt(col -> col.getEdges().size()).distinct().count()) { throw new IncompatibleColumnsException("Not all of the columns are of the same height!"); } final int columnHeight = this.columns.iterator().next().getEdges().size(); if (rowContainer.getRowCount() != columnHeight) { throw new ColumnToRowIncompatibilityException("The column height is not equal to the row count!"); } if (!rowContainer.getRows().stream().map(AssignmentGraph.UnrestrictedGraph.SubGraph::edgeSet) .flatMap(Set::stream).collect(toIdentityHashSet()).equals(this.columns.stream() .flatMap(col -> col.getEdges().stream()).collect(toIdentityHashSet()))) { throw new ColumnToRowIncompatibilityException( "The set of edges in the columns is not identical to the set of edges in the rows!"); } } return true; }
From source file:soot.jimple.infoflow.data.Abstraction.java
@Override public void addNeighbor(Abstraction originalAbstraction) { // We should not register ourselves as a neighbor if (originalAbstraction == this) return;/*from w ww .ja v a 2 s .c o m*/ // We should not add identical nodes as neighbors if (this.predecessor == originalAbstraction.predecessor && this.currentStmt == originalAbstraction.currentStmt && this.predecessor == originalAbstraction.predecessor) return; synchronized (this) { if (neighbors == null) neighbors = Sets.newIdentityHashSet(); else if (InfoflowConfiguration.getMergeNeighbors()) { // Check if we already have an identical neighbor for (Abstraction nb : neighbors) { if (nb == originalAbstraction) return; if (originalAbstraction.predecessor == nb.predecessor && originalAbstraction.currentStmt == nb.currentStmt && originalAbstraction.correspondingCallSite == nb.correspondingCallSite) { return; } } } this.neighbors.add(originalAbstraction); } }
From source file:com.android.tools.idea.uibuilder.model.NlModel.java
private void checkStructure() { if (CHECK_MODEL_INTEGRITY) { ApplicationManager.getApplication().runReadAction(() -> { Set<NlComponent> unique = Sets.newIdentityHashSet(); Set<XmlTag> uniqueTags = Sets.newIdentityHashSet(); checkUnique(myFile.getRootTag(), uniqueTags); uniqueTags.clear();//from w ww. ja v a2s .com for (NlComponent component : myComponents) { checkUnique(component.getTag(), uniqueTags); checkUnique(component, unique); } for (NlComponent component : myComponents) { checkStructure(component); } }); } }
From source file:com.android.build.gradle.internal.DependencyManager.java
public Set<AndroidDependency> resolveDependencies(@NonNull VariantDependencies variantDeps, @Nullable String testedProjectPath) { // set of Android Libraries to explode. This only concerns remote libraries, as modules // are now used through their staging folders rather than their bundled AARs. // Therefore there is no dependency on these exploded tasks since remote AARs are // downloaded during the dependency resolution process. // because they are not immutable (them or the children could be skipped()), we use // an identity set. Set<AndroidDependency> libsToExplode = Sets.newIdentityHashSet(); resolveDependencies(variantDeps, testedProjectPath, libsToExplode); return libsToExplode; }
From source file:edu.buaa.satla.analysis.core.predicate.PredicateAbstractionRefinementStrategy.java
/** * Collect all precisions in the subgraph below refinementRoot and merge * their predicates./*from w ww .j a v a 2s . com*/ * @return a new precision with all these predicates. */ private PredicatePrecision findAllPredicatesFromSubgraph(ARGState refinementRoot, UnmodifiableReachedSet reached) { PredicatePrecision newPrecision = PredicatePrecision.empty(); // find all distinct precisions to merge them Set<Precision> precisions = Sets.newIdentityHashSet(); for (ARGState state : refinementRoot.getSubgraph()) { if (!state.isCovered()) { // covered states are not in reached set precisions.add(reached.getPrecision(state)); } } for (Precision prec : precisions) { newPrecision = newPrecision.mergeWith(extractPredicatePrecision(prec)); } return newPrecision; }
From source file:org.apache.twill.yarn.YarnTwillPreparer.java
private void createApplicationJar(final ApplicationBundler bundler, Map<String, LocalFile> localFiles) throws IOException { try {//w ww . ja va 2 s . co m final Set<Class<?>> classes = Sets.newIdentityHashSet(); classes.addAll(dependencies); ClassLoader classLoader = getClassLoader(); for (RuntimeSpecification spec : twillSpec.getRunnables().values()) { classes.add(classLoader.loadClass(spec.getRunnableSpecification().getClassName())); } // Add the TwillRunnableEventHandler class if (twillSpec.getEventHandler() != null) { classes.add(getClassLoader().loadClass(twillSpec.getEventHandler().getClassName())); } // The location name is computed from the MD5 of all the classes names // The localized name is always APPLICATION_JAR List<String> classList = Lists.newArrayList(Iterables.transform(classes, CLASS_TO_NAME)); Collections.sort(classList); Hasher hasher = Hashing.md5().newHasher(); for (String name : classList) { hasher.putString(name); } // Only depends on class list so that it can be reused across different launches String name = hasher.hash().toString() + "-" + Constants.Files.APPLICATION_JAR; LOG.debug("Create and copy {}", Constants.Files.APPLICATION_JAR); Location location = locationCache.get(name, new LocationCache.Loader() { @Override public void load(String name, Location targetLocation) throws IOException { bundler.createBundle(targetLocation, classes); } }); LOG.debug("Done {}", Constants.Files.APPLICATION_JAR); localFiles.put(Constants.Files.APPLICATION_JAR, createLocalFile(Constants.Files.APPLICATION_JAR, location, true)); } catch (ClassNotFoundException e) { throw Throwables.propagate(e); } }