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.predicate.PredicateAbstractionRefinementStrategy.java
private VariableTrackingPrecision mergeAllValuePrecisionsFromSubgraph(ARGState refinementRoot, UnmodifiableReachedSet reached) { VariableTrackingPrecision rootPrecision = Precisions .extractPrecisionByType(reached.getPrecision(refinementRoot), VariableTrackingPrecision.class); // 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)); }//from w w w . jav a 2 s. com } for (Precision prec : precisions) { rootPrecision = rootPrecision .join(Precisions.extractPrecisionByType(prec, VariableTrackingPrecision.class)); } return rootPrecision; }
From source file:org.jamocha.dn.compiler.ecblocks.IncompleteBlock.java
private static ArrayList<Edge<ECOccurrenceNode, BindingNode>> getGreedyMaximalMatching( final Block.RowContainer rowContainer, final ArrayList<Edge<ECOccurrenceNode, BindingNode>> shuffledEdges) { // helper lookup map from node to row final Map<AssignmentGraphNode<?>, RowIdentifier> node2Row = new IdentityHashMap<>(); // helper set of rows already in the matching final Set<RowIdentifier> rowsInMatching = Sets.newIdentityHashSet(); // result container final ArrayList<Edge<ECOccurrenceNode, BindingNode>> maximalMatching = new ArrayList<>(); for (final Edge<ECOccurrenceNode, BindingNode> edge : shuffledEdges) { final ECOccurrenceNode source = edge.getSource(); // determine and cache block row of source node or (if not part of the block) create a new row for it final RowIdentifier sourceRow = node2Row.computeIfAbsent(source, x -> Optional.ofNullable(rowContainer.getRowIdentifier(source)).orElseGet(RowIdentifier::new)); if (rowsInMatching.contains(sourceRow)) continue; final BindingNode target = edge.getTarget(); // same as above for target node final RowIdentifier targetRow = node2Row.computeIfAbsent(target, x -> Optional.ofNullable(rowContainer.getRowIdentifier(target)).orElseGet(RowIdentifier::new)); if (rowsInMatching.contains(targetRow)) continue; rowsInMatching.add(sourceRow);/*from www.j a va 2s.co m*/ rowsInMatching.add(targetRow); maximalMatching.add(edge); } return maximalMatching; }
From source file:com.google.template.soy.jbcsrc.TemplateAnalysis.java
/** * Traverses the control flow graph reachable from {@code start} and adds all the predecessor * links./*w w w .j a v a 2 s .c o m*/ */ private static void addPredecessors(Block start) { Set<Block> visited = Sets.newIdentityHashSet(); addPredecessors(start, visited); }
From source file:com.google.javascript.jscomp.TypeInference.java
private Map<TemplateType, JSType> inferTemplateTypesFromParameters(FunctionType fnType, Node call) { if (fnType.getTemplateTypeMap().getTemplateKeys().isEmpty()) { return Collections.emptyMap(); }/*from www . j ava 2s. c o m*/ Map<TemplateType, JSType> resolvedTypes = Maps.newIdentityHashMap(); Set<JSType> seenTypes = Sets.newIdentityHashSet(); Node callTarget = call.getFirstChild(); if (NodeUtil.isGet(callTarget)) { Node obj = callTarget.getFirstChild(); maybeResolveTemplatedType(fnType.getTypeOfThis(), getJSType(obj), resolvedTypes, seenTypes); } if (call.hasMoreThanOneChild()) { maybeResolveTemplateTypeFromNodes(fnType.getParameters(), call.getChildAtIndex(1).siblings(), resolvedTypes, seenTypes); } return resolvedTypes; }
From source file:org.apache.calcite.linq4j.EnumerableDefaults.java
/** * Correlates the elements of two sequences based on a predicate. *///from w w w . ja v a 2 s. c o m public static <TSource, TInner, TResult> Enumerable<TResult> thetaJoin(final Enumerable<TSource> outer, final Enumerable<TInner> inner, final Predicate2<TSource, TInner> predicate, Function2<TSource, TInner, TResult> resultSelector, final boolean generateNullsOnLeft, final boolean generateNullsOnRight) { // Building the result as a list is easy but hogs memory. We should iterate. final List<TResult> result = Lists.newArrayList(); final Enumerator<TSource> lefts = outer.enumerator(); final List<TInner> rightList = inner.toList(); final Set<TInner> rightUnmatched; if (generateNullsOnLeft) { rightUnmatched = Sets.newIdentityHashSet(); rightUnmatched.addAll(rightList); } else { rightUnmatched = null; } while (lefts.moveNext()) { int leftMatchCount = 0; final TSource left = lefts.current(); final Enumerator<TInner> rights = Linq4j.iterableEnumerator(rightList); while (rights.moveNext()) { TInner right = rights.current(); if (predicate.apply(left, right)) { ++leftMatchCount; if (rightUnmatched != null) { rightUnmatched.remove(right); } result.add(resultSelector.apply(left, right)); } } if (generateNullsOnRight && leftMatchCount == 0) { result.add(resultSelector.apply(left, null)); } } if (rightUnmatched != null) { final Enumerator<TInner> rights = Linq4j.iterableEnumerator(rightUnmatched); while (rights.moveNext()) { TInner right = rights.current(); result.add(resultSelector.apply(null, right)); } } return Linq4j.asEnumerable(result); }
From source file:org.jetbrains.kotlin.resolve.DescriptorResolver.java
public static void registerFileInPackage(@NotNull BindingTrace trace, @NotNull KtFile file) { // Register files corresponding to this package // The trace currently does not support bi-di multimaps that would handle this task nicer FqName fqName = file.getPackageFqName(); Collection<KtFile> files = trace.get(PACKAGE_TO_FILES, fqName); if (files == null) { files = Sets.newIdentityHashSet(); }/*from w ww. j a v a 2s . co m*/ files.add(file); trace.record(BindingContext.PACKAGE_TO_FILES, fqName, files); }