moveChild

fun moveChild(child: TreeNode<T>, toIndex: Int): Boolean(source)

Moves an existing direct child to a new position within this node's children.

toIndex is coerced into the valid range, so out-of-range targets clamp to the first or last position. Because child is already a direct child, no re-parenting or cycle check is needed.

Return

true if child was a direct child and has been moved; false otherwise.

Parameters

child

the node to reorder; must already be a direct child of this node.

toIndex

the target position for child after removal, coerced into 0..children.size.