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

Method IndexInParent

tree/nodebase.go:149–156  ·  view source on GitHub ↗

Parents: IndexInParent returns our index within our parent node. It caches the last value and uses that for an optimized search so subsequent calls are typically quite fast. Returns -1 if we don't have a parent.

()

Source from the content-addressed store, hash-verified

147// last value and uses that for an optimized search so subsequent calls
148// are typically quite fast. Returns -1 if we don't have a parent.
149func (n *NodeBase) IndexInParent() int {
150 if n.Parent == nil {
151 return -1
152 }
153 idx := IndexOf(n.Parent.AsTree().Children, n.This, n.index) // very fast if index is close
154 n.index = idx
155 return idx
156}
157
158// ParentLevel finds a given potential parent node recursively up the
159// hierarchy, returning the level above the current node that the parent was

Callers 15

UnmarshalJSONMethod · 0.95
handleElementFunction · 0.80
InitMethod · 0.80
insertAtMethod · 0.80
DuplicateMethod · 0.80
duplicateSyncMethod · 0.80
pasteAtSyncMethod · 0.80
moveDownSiblingMethod · 0.80
moveUpMethod · 0.80
pasteAtMethod · 0.80
widgetNextSiblingFunction · 0.80
widgetPrevFunction · 0.80

Calls 2

IndexOfFunction · 0.85
AsTreeMethod · 0.65

Tested by

no test coverage detected