Annotation of libwww/Library/src/HTBTree.html, revision 2.7

2.7     ! timbl       1: <HEADER>
        !             2: <TITLE>/Net/dxcern/userd/timbl/hypertext/WWW/Library/Implementation/HTBTree.html</TITLE>
        !             3: <NEXTID N="1">
        !             4: </HEADER>
        !             5: <BODY>
        !             6: <H1>Balanced Binary Tree for sorting
        !             7: things</H1>Tree creation, traversal and freeing.
        !             8:  User-supplied comparison routine.<P>
        !             9: Author: Arthur Secret, CERN. Public
        !            10: domain.  Please mail bugs and changes
        !            11: to www-request@info.cern.ch<P>
        !            12: part of <A
        !            13: NAME=z0 HREF="Overview.html">libWWW</A>
        !            14: <PRE>#ifdef SHORT_NAMES
        !            15: #define        HTBTree_new             HTBTNew
        !            16: #define        HTBTree_free            HTBTFree
        !            17: #define HTBTreeAndObject_free  HTBTAOFr
        !            18: #define HTBTree_add            HTBTAdd
        !            19: #define        HTBTree_next            HTBTNext
        !            20: /* #define     HTBTree_object          HTBTObje already a macro */
        !            21: #endif
1.1       timbl      22: 
                     23: 
2.7     ! timbl      24: </PRE>
        !            25: <H2>Data structures</H2>
        !            26: <PRE>typedef struct _HTBTree_element {
1.1       timbl      27:     void                       *object;        /* User object */
                     28:     struct _HTBTree_element    *up;
                     29:     struct _HTBTree_element    *left;
                     30:     int                                left_depth;
                     31:     struct _HTBTree_element    *right;
                     32:     int                                right_depth;
                     33: } HTBTElement;
                     34: 
2.6       secret     35: typedef int (*HTComparer) PARAMS((void * a, void * b));
1.1       timbl      36: 
                     37: typedef struct _HTBTree_top {
                     38:     HTComparer                 compare;
                     39:     struct _HTBTree_element    *top;   
                     40: } HTBTree;
                     41: 
                     42: 
2.7     ! timbl      43: </PRE>
        !            44: <H2>Create a binary tree given its discrimination
        !            45: routine</H2>
        !            46: <PRE>extern HTBTree * HTBTree_new PARAMS((HTComparer comp));
1.1       timbl      47: 
                     48: 
                     49: 
2.7     ! timbl      50: </PRE>
        !            51: <H2>Free storage of the tree but not
        !            52: of the objects</H2>
        !            53: <PRE>extern void HTBTree_free PARAMS((HTBTree* tree));
2.6       secret     54: 
                     55: 
                     56: 
2.7     ! timbl      57: </PRE>
        !            58: <H2>Free storage of the tree and of the
        !            59: objects</H2>
        !            60: <PRE>extern void HTBTreeAndObject_free PARAMS((HTBTree* tree));
2.6       secret     61: 
                     62: 
1.1       timbl      63: 
2.7     ! timbl      64: </PRE>
        !            65: <H2>Add an object to a binary tree</H2>
        !            66: <PRE>
        !            67: extern void HTBTree_add PARAMS((HTBTree* tree, void * object));
1.1       timbl      68: 
                     69: 
2.7     ! timbl      70: </PRE>
        !            71: <H2>Find user object for element</H2>
        !            72: <PRE>#define HTBTree_object(element)  ((element)->object)
1.1       timbl      73: 
                     74: 
2.7     ! timbl      75: </PRE>
        !            76: <H2>Find next element in depth-first
        !            77: order</H2>
        !            78: <H3>On entry,</H3>
        !            79: <DL>
        !            80: <DT>ele
        !            81: <DD>if NULL, start with leftmost element.
        !            82: if != 0 give next object to the right.
        !            83: <DT>returns
        !            84: <DD>Pointer to element ot NULL
        !            85: if none left.
        !            86: </DL>
1.1       timbl      87: 
2.7     ! timbl      88: <PRE>extern HTBTElement * HTBTree_next PARAMS((HTBTree* tree, HTBTElement * ele));
1.1       timbl      89: 
2.7     ! timbl      90: </PRE>end</BODY>

Webmaster