RemoveAt removes the child at the specified index.
(idx int)
| 431 | |
| 432 | // RemoveAt removes the child at the specified index. |
| 433 | func (n *Node) RemoveAt(idx int) INode { |
| 434 | |
| 435 | // Validate position |
| 436 | if idx < 0 || idx >= len(n.children) { |
| 437 | panic("Node.RemoveAt: invalid position") |
| 438 | } |
| 439 | |
| 440 | child := n.children[idx] |
| 441 | |
| 442 | // Remove child from children list |
| 443 | copy(n.children[idx:], n.children[idx+1:]) |
| 444 | n.children[len(n.children)-1] = nil |
| 445 | n.children = n.children[:len(n.children)-1] |
| 446 | |
| 447 | n.Dispatch(OnDescendant, nil) |
| 448 | |
| 449 | return child |
| 450 | } |
| 451 | |
| 452 | // RemoveAll removes all children. |
| 453 | func (n *Node) RemoveAll(recurs bool) { |