MCPcopy
hub / github.com/google/mangle / find

Method find

unionfind/unionfind.go:78–92  ·  view source on GitHub ↗

Find the representative element from the set of s.

(s ast.BaseTerm)

Source from the content-addressed store, hash-verified

76
77// Find the representative element from the set of s.
78func (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.
95func (uf UnionFind) unify(v ast.Variable, t ast.BaseTerm) bool {

Callers 8

AsConstSubstListMethod · 0.95
unionMethod · 0.95
unifyMethod · 0.95
GetMethod · 0.95
UnifyTermsExtendFunction · 0.95
unifyTermsUpdateFunction · 0.80
UnifyTypeExprFunction · 0.80
unifyFunctionalMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected