/** Get the snapshot of union find */ ImmutableMap<ECR, Collection<IRVar>> snapshot() { SetMultimap<Partition, IRVar> map = uf.snapshot(); ImmutableMap.Builder<ECR, Collection<IRVar>> builder = ImmutableMap.builder(); for (Partition ecr : map.asMap().keySet()) { builder.put(findRoot((ECR) ecr), ImmutableSet.copyOf(map.asMap().get(ecr))); } return builder.build(); }
/** * ECR-union e1 and e2, return the updated root * * @param e1 * @param e2 * @return */ private ECR union(ECR e1, ECR e2) { uf.union(e1, e2); return findRoot(e1); }
/** * Add <code>var</code> into union find * * @param var */ void add(VarImpl var) { uf.add(var, var.getECR()); }
Collection<IRVar> getEquivClass(ECR key) { return uf.getEquivClass(key); }
void reset() { uf.reset(); }
private UnionFindECR() { uf = UnionFind.create(); }