Compact will remove unecessay nodes, reducing the capacity, returning true if node n itself should be removed.
()
| 97 | |
| 98 | // Compact will remove unecessay nodes, reducing the capacity, returning true if node n itself should be removed. |
| 99 | func (n *Node) Compact() (remove bool) { |
| 100 | |
| 101 | for r, c := range n.children { |
| 102 | if c.Compact() { |
| 103 | delete(n.children, r) |
| 104 | } |
| 105 | } |
| 106 | return !n.isLeaf && len(n.children) == 0 |
| 107 | } |
no outgoing calls