Ignore:
Timestamp:
Nov 23, 2000, 7:36:41 PM (25 years ago)
Author:
umoeller
Message:

Updates for V0.9.6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/tree.c

    r11 r13  
    1515 *      This has been taken from the Standard Function Library (SFL)
    1616 *      by iMatix Corporation and changed to user the "id" member for
    17  *      tree sorting/comparison.
     17 *      tree sorting/comparison. This implementation is released
     18 *      under the GPL.
    1819 *
    1920 *      <B>Using binary trees</B>
     21 *
     22 *      You can use any structure as elements in a tree, provided
     23 *      that the first member in the structure is a TREE structure
     24 *      (i.e. it has the left, right, parent, id, and colour members).
     25 *      The tree functions don't care what follows.
     26 *
     27 *      So the implementation here is slightly different from the
     28 *      linked lists in linklist.c, because the LISTNODE structs
     29 *      only have pointers to the data. By contrast, the TREE structs
     30 *      are expected to contain the data themselves. See treeInsertID()
     31 *      for a sample.
    2032 *
    2133 *      Each TREE node does not only contain data, but also an
     
    5567 *      Differences compared to linklist.c:
    5668 *
     69 *      -- Trees are considerably slower when inserting and removing
     70 *         nodes because the tree has to be rebalanced every time
     71 *         a node changes. By contrast, trees are much faster finding
     72 *         nodes because the tree is always sorted.
     73 *
     74 *      -- You must always supply a comparison function to allow the
     75 *         tree functions to sort the tree.
     76 *
    5777 *      -- As opposed to a LISTNODE, the TREE structure (which
    58  *         represents a tree node) does not contain a data pointer.
    59  *         Instead, all tree nodes are assumed to contain the
    60  *         data themselves. As a result, you must define your
    61  *         own structures which start with a TREE structure.
    62  *
    63  *         See treeInsertID() for samples.
    64  *
    65  *      -- You must supply a comparison function to allow the
    66  *         tree functions to sort the tree.
     78 *         represents a tree node) does not contain a data pointer,
     79 *         as said above.
    6780 *
    6881 *@@added V0.9.5 (2000-09-29) [umoeller]
     
    838851 *      and will receive the "pUser" parameter, which you can use
    839852 *      as a data pointer to some structure for whatever you like.
    840  */
    841 
    842 void treeTraverse(TREE *tree,
    843                   TREE_PROCESS *process,
    844                   void *pUser,
    845                   int method)
     853 *
     854 *      "method" specifies in which order the nodes are traversed.
     855 *      This can be:
     856 *
     857 *      -- 1: current node first, then left node, then right node.
     858 *      -- 2: left node first, then right node, then current node.
     859 *      -- other: left node first, then current node, then right node.
     860 */
     861
     862void treeTraverse(TREE *tree,               // in: root of tree
     863                  TREE_PROCESS *process,    // in: callback for each node
     864                  void *pUser,              // in: user param for callback
     865                  int method)               // in: traversal mode
    846866{
    847867    if ((!tree)
Note: See TracChangeset for help on using the changeset viewer.