MCPcopy Create free account
hub / github.com/cogentcore/core / findPathChild

Function findPathChild

tree/nodebase.go:289–301  ·  view source on GitHub ↗

findPathChild finds the child with the given string representation in [NodeBase.FindPath].

(n Node, child string)

Source from the content-addressed store, hash-verified

287
288// findPathChild finds the child with the given string representation in [NodeBase.FindPath].
289func findPathChild(n Node, child string) int {
290 if child[0] == '[' && child[len(child)-1] == ']' {
291 idx, err := strconv.Atoi(child[1 : len(child)-1])
292 if err != nil {
293 return idx
294 }
295 if idx < 0 { // from end
296 idx = len(n.AsTree().Children) + idx
297 }
298 return idx
299 }
300 return IndexByName(n.AsTree().Children, child)
301}
302
303// Adding and Inserting Children:
304

Callers 1

FindPathMethod · 0.85

Calls 2

IndexByNameFunction · 0.85
AsTreeMethod · 0.65

Tested by

no test coverage detected