MCPcopy Index your code
hub / github.com/g3n/engine / IsAncestorOf

Method IsAncestorOf

core/node.go:378–393  ·  view source on GitHub ↗

IsAncestorOf returns whether this node is an ancestor of the specified node. Returns true if they are the same.

(desc INode)

Source from the content-addressed store, hash-verified

376
377// IsAncestorOf returns whether this node is an ancestor of the specified node. Returns true if they are the same.
378func (n *Node) IsAncestorOf(desc INode) bool {
379
380 if desc == nil {
381 return false
382 }
383 if n == desc.GetNode() {
384 return true
385 }
386 for _, child := range n.Children() {
387 res := child.IsAncestorOf(desc)
388 if res {
389 return res
390 }
391 }
392 return false
393}
394
395// LowestCommonAncestor returns the common ancestor of this node and the specified node if any.
396func (n *Node) LowestCommonAncestor(other INode) INode {

Callers

nothing calls this directly

Calls 3

ChildrenMethod · 0.95
GetNodeMethod · 0.65
IsAncestorOfMethod · 0.65

Tested by

no test coverage detected