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

2.8       frystyk     1: <HTML>
                      2: <HEAD>
                      3: <TITLE>Balanced Binary Tree</TITLE>
                      4: </HEAD>
2.7       timbl       5: <BODY>
2.10    ! frystyk     6: 
2.8       frystyk     7: <H1>Balanced Binary Tree</H1>
                      8: 
                      9: <PRE>
                     10: /*
                     11: **     (c) COPYRIGHT CERN 1994.
                     12: **     Please first read the full copyright statement in the file COPYRIGH.
                     13: */
                     14: </PRE>
                     15: 
                     16: Tree creation, traversal and freeing. User-supplied comparison
                     17: routine.<P>
                     18: 
                     19: This module is implemented by <A HREF="HTBTree.c">HTBTree.c</A>, and
                     20: it is a part of the <A
                     21: HREF="http://info.cern.ch/hypertext/WWW/Library/User/Guide/Guide.html">
                     22: Library of Common Code</A>.
                     23: 
                     24: <PRE>
2.10    ! frystyk    25: #ifndef HTBTTEE_H
        !            26: #define HTBTREE_H
1.1       timbl      27: 
2.10    ! frystyk    28: </PRE>
1.1       timbl      29: 
2.7       timbl      30: <H2>Data structures</H2>
                     31: <PRE>typedef struct _HTBTree_element {
1.1       timbl      32:     void                       *object;        /* User object */
                     33:     struct _HTBTree_element    *up;
                     34:     struct _HTBTree_element    *left;
                     35:     int                                left_depth;
                     36:     struct _HTBTree_element    *right;
                     37:     int                                right_depth;
                     38: } HTBTElement;
                     39: 
2.6       secret     40: typedef int (*HTComparer) PARAMS((void * a, void * b));
1.1       timbl      41: 
                     42: typedef struct _HTBTree_top {
                     43:     HTComparer                 compare;
                     44:     struct _HTBTree_element    *top;   
                     45: } HTBTree;
                     46: 
                     47: 
2.7       timbl      48: </PRE>
                     49: <H2>Create a binary tree given its discrimination
                     50: routine</H2>
                     51: <PRE>extern HTBTree * HTBTree_new PARAMS((HTComparer comp));
1.1       timbl      52: 
                     53: 
                     54: 
2.7       timbl      55: </PRE>
                     56: <H2>Free storage of the tree but not
                     57: of the objects</H2>
                     58: <PRE>extern void HTBTree_free PARAMS((HTBTree* tree));
2.6       secret     59: 
                     60: 
                     61: 
2.7       timbl      62: </PRE>
                     63: <H2>Free storage of the tree and of the
                     64: objects</H2>
                     65: <PRE>extern void HTBTreeAndObject_free PARAMS((HTBTree* tree));
2.6       secret     66: 
                     67: 
1.1       timbl      68: 
2.7       timbl      69: </PRE>
                     70: <H2>Add an object to a binary tree</H2>
                     71: <PRE>
                     72: extern void HTBTree_add PARAMS((HTBTree* tree, void * object));
1.1       timbl      73: 
                     74: 
2.7       timbl      75: </PRE>
                     76: <H2>Find user object for element</H2>
                     77: <PRE>#define HTBTree_object(element)  ((element)->object)
1.1       timbl      78: 
                     79: 
2.7       timbl      80: </PRE>
                     81: <H2>Find next element in depth-first
                     82: order</H2>
                     83: <H3>On entry,</H3>
                     84: <DL>
                     85: <DT>ele
                     86: <DD>if NULL, start with leftmost element.
                     87: if != 0 give next object to the right.
                     88: <DT>returns
                     89: <DD>Pointer to element ot NULL
                     90: if none left.
                     91: </DL>
1.1       timbl      92: 
2.7       timbl      93: <PRE>extern HTBTElement * HTBTree_next PARAMS((HTBTree* tree, HTBTElement * ele));
1.1       timbl      94: 
2.10    ! frystyk    95: #endif
        !            96: </PRE>
        !            97: end
        !            98: </BODY>
        !            99: </HTML>

Webmaster