Find the representative element from the set of s.
(s ast.BaseTerm)
| 76 | |
| 77 | // Find the representative element from the set of s. |
| 78 | func (uf UnionFind) find(s ast.BaseTerm) ast.BaseTerm { |
| 79 | child := s |
| 80 | parent := uf.parent[child] |
| 81 | if parent == nil { |
| 82 | return nil |
| 83 | } |
| 84 | for child != parent { |
| 85 | grandparent := uf.parent[parent] |
| 86 | // Optimize the next lookup |
| 87 | uf.parent[child] = grandparent |
| 88 | child = grandparent |
| 89 | parent = uf.parent[child] |
| 90 | } |
| 91 | return parent |
| 92 | } |
| 93 | |
| 94 | // Returns true if v can be unified with t, updates unionfind sets. |
| 95 | func (uf UnionFind) unify(v ast.Variable, t ast.BaseTerm) bool { |
no outgoing calls
no test coverage detected