19.0.0 released Nov 08, 2023
Purge tree

Purpose: Delete a tree.

purge-tree <tree>

purge-tree will delete a <tree> created with new-tree. All of <tree>'s nodes, and their keys/values (if allocated) must be deleted prior to purge-tree. Here's an example of doing that, by finding a node with the minimum key, deleting it, and repeating the process:
while (1) {
    read-tree mytree min-key old-key define mk value define mv status define ms
    if (ms == VV_OKAY) {
        delete-tree mytree key mk
        delete-mem mk
        delete-mem mv
    } else break;

See memory-handling for more on when (not) to delete memory explicitly like this; the same rules apply as for delete-mem.
Delete a tree entirely:
new-tree define mytree
purge-tree mytree

See also
Tree search
See all

You are free to copy, redistribute and adapt this web page (even commercially), as long as you give credit and provide a dofollow link back to this page - see full license at CC-BY-4.0. Copyright (c) 2019-2023 Dasoftver LLC. Vely and elephant logo are trademarks of Dasoftver LLC. The software and information on this web site are provided "AS IS" and without any warranties or guarantees of any kind. Icons from table-icons.io copyright PaweĊ‚ Kuna, licensed under MIT license.