Gambas Documentation - /comp/gb.data/avltree/clear

# AvlTree.Clear (gb.data)

Sub Clear ( )

Clear the tree, i.e. remove all elements. This is way faster than removing every element by assigning Null to it like

    For Each v In hTree
      hTree[hTree.Key] = Null
    Next

because removing an element may require to rebalance the tree at most hTree.Height times. For each element, this is a great overhead to have an empty tree.

So use hTree.Clear() if the tree shall be emptied.