List of usage examples for com.google.common.collect Sets newIdentityHashSet
public static <E> Set<E> newIdentityHashSet()
From source file:compile.type.visit.TypeParamCollector.java
private Set<TypeParam> process(final Type type) { params = Sets.newIdentityHashSet(); visitType(type); return params; }
From source file:org.fiware.kiara.impl.IDLInfo.java
public IDLInfo(String idlContents) throws IDLParseException { this.idlContents = idlContents; this.servants = Sets.newIdentityHashSet(); this.serviceTypes = new ArrayList<>(); final ParserContextImpl ctx = IDLUtils.loadIDL(idlContents, "stdin"); serviceTypes.addAll(TypeMapper.getServiceTypes(ctx)); }
From source file:compile.type.TypeVar.java
private TypeVar(final Loc loc, final String name, final Kind kind, final Constraint constraint, final TypeParam sourceParam) { super(loc);/* ww w . java 2 s . co m*/ this.name = name; this.kind = kind; this.constraint = constraint; this.sourceParam = sourceParam; this.unifiedParams = Sets.newIdentityHashSet(); if (sourceParam != null) unifiedParams.add(sourceParam); if (kind == null) assert false : "null kind in TypeVar ctor: " + name; if (constraint == null) assert false : "null constraint in TypeVar ctor: " + name; }
From source file:com.greensopinion.finance.services.transaction.TransactionNormalizer.java
/** * Removes transaction pairs that are self-canceling. *///w w w . j a v a 2 s . com public List<Transaction> normalize(List<Transaction> transactions) { List<Transaction> normalizedTransactions = new ArrayList<>(transactions); ListMultimap<Long, Transaction> transactionByAbsoluteValue = ArrayListMultimap.create(); for (Transaction transaction : transactions) { transactionByAbsoluteValue.put(Math.abs(transaction.getAmount()), transaction); } for (Long amount : transactionByAbsoluteValue.keySet()) { List<Transaction> list = transactionByAbsoluteValue.get(amount); Set<Transaction> canceledOut = Sets.newIdentityHashSet(); for (Transaction transaction : list) { if (canceledOut.contains(transaction)) { continue; } for (Transaction transaction2 : list) { if (transaction.getAmount() == -transaction2.getAmount() && !canceledOut.contains(transaction2)) { canceledOut.add(transaction); canceledOut.add(transaction2); break; } } } normalizedTransactions.removeAll(canceledOut); } return normalizedTransactions; }
From source file:org.jamocha.dn.compiler.ecblocks.assignmentgraph.ConnectedComponentCounter.java
public int countConnectedComponents() { final Set<AssignmentGraphNode<?>> allNodes = Sets.newIdentityHashSet(); allNodes.addAll(this.subgraph.bindingNodeSet()); allNodes.addAll(this.subgraph.occurrenceNodeSet()); while (!allNodes.isEmpty()) { final AssignmentGraphNode<?> node = allNodes.iterator().next(); this.queued.add(node); this.queue.add(node); node.accept(this); allNodes.removeAll(this.done); this.connectedComponents++; }/* w ww. j a v a 2s . c o m*/ return this.connectedComponents; }
From source file:co.cask.cdap.internal.io.ReflectionWriter.java
public void write(TYPE object, WRITER writer) throws IOException { seenRefs = Sets.newIdentityHashSet(); write(writer, object, schema); }
From source file:co.cask.cdap.internal.io.ReflectionDatumWriter.java
@Override public void encode(T data, Encoder encoder) throws IOException { Set<Object> seenRefs = Sets.newIdentityHashSet(); write(data, encoder, schema, seenRefs); }
From source file:com.google.inject.servlet.AbstractServletPipeline.java
void init(ServletContext servletContext, Injector injector) throws ServletException { Set<HttpServlet> initializedSoFar = Sets.newIdentityHashSet(); for (ServletDefinition servletDefinition : servletDefinitions()) { servletDefinition.init(servletContext, injector, initializedSoFar); }//from w w w. ja v a2s. c o m }
From source file:com.yahoo.yqlplus.engine.internal.tasks.GraphPlanner.java
private void populateAvailable(Node node, Set<Value> available, Map<Step, Node> nodes) { for (Step src : node.todo) { available.add(src.getOutput());/* ww w .j a v a 2s . c o m*/ } node.available.addAll(available); for (Step dst : node.deps) { Set<Value> copy = Sets.newIdentityHashSet(); copy.addAll(available); populateAvailable(nodes.get(dst), copy, nodes); } }
From source file:org.apache.drill.exec.planner.physical.SubsetTransformer.java
public boolean go(T n, RelNode candidateSet) throws E { if (!(candidateSet instanceof RelSubset)) { return false; }//from ww w .j a v a 2 s . c o m boolean transform = false; Set<RelNode> transformedRels = Sets.newIdentityHashSet(); Set<RelTraitSet> traitSets = Sets.newHashSet(); //1, get all the target traitsets from candidateSet's rel list, for (RelNode rel : ((RelSubset) candidateSet).getRelList()) { if (isPhysical(rel)) { final RelTraitSet relTraitSet = rel.getTraitSet(); if (!traitSets.contains(relTraitSet)) { traitSets.add(relTraitSet); logger.trace("{}.convertChild get traitSet {}", this.getClass().getSimpleName(), relTraitSet); } } } //2, convert the candidateSet to targeted taitSets for (RelTraitSet traitSet : traitSets) { RelNode newRel = RelOptRule.convert(candidateSet, traitSet.simplify()); if (transformedRels.contains(newRel)) { continue; } transformedRels.add(newRel); logger.trace("{}.convertChild to convert NODE {} ,AND {}", this.getClass().getSimpleName(), n, newRel); RelNode out = convertChild(n, newRel); //RelNode out = convertChild(n, rel); if (out != null) { call.transformTo(out); transform = true; } } return transform; }