home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / nn.tar / nn-6.5.1 / contrib / nnsub / avl.h < prev    next >
C/C++ Source or Header  |  1995-04-29  |  2KB  |  59 lines

  1. /*
  2.     routines for handling AVL tree
  3.  
  4.     Copyright
  5.     Rudi van Houten, Academic Computer Centre Utrecht
  6.              Budapestlaan 6  3584 CD  Utrecht  Netherlands
  7.     Author : Rudi van Houten
  8.  
  9.     The field content is here defined as a character pointer
  10.     but all references to it are made outside these routines
  11.     e.g. the parameter function CNTCMP so the calling program
  12.     is free to use a different definition. In the comments
  13.     this pointertype is called CONTENT.
  14.     The routine CNTCMP is called with two parameters of the
  15.     type CONTENT, and yields an integer value:
  16.         < 0    if 1st par < 2nd par
  17.         = 0    if 1st par = 2nd par
  18.         > 0    if 1st par > 2nd par
  19.     e.g. the routine strcmp.
  20. */
  21. #include <stdio.h>
  22. extern char * strsave();
  23.  
  24. typedef struct avl_node
  25.             { char * content;                 /* pointer to data */
  26.               short  balance;                 /* balance the tree */
  27.               struct avl_node *left, *right;  /* tree pointers */
  28.             } AVL_NODE;
  29.  
  30. typedef AVL_NODE * P_AVL_NODE;
  31.  
  32. extern int insert_avl();
  33.     /* parameterplan: (value,tree,CNTCMP,rtnval)
  34.                       CONTENT value, *rtnval;
  35.                       P_AVL_NODE *tree;
  36.                       int (*CNTCMP)();
  37.         the variable rtnval yields a reference to the
  38.         datastructure in the found AVL_NODE, it will
  39.         be equal to value if a new node is created.
  40.     */
  41.  
  42. extern int insavlnode();
  43.     /* parameterplan: (node,p,CNTCMP)
  44.                       P_AVL_NODE node, *p;
  45.                       int (*CNTCMP)();
  46.     */
  47. extern P_AVL_NODE find_avlnode();
  48.     /* parameterplan: (value,tree,CNTCMP)
  49.                       CONTENT value;
  50.                       P_AVL_NODE tree;
  51.                       int (*CNTCMP)();
  52.     */
  53. extern int unravel_avl();
  54.     /* parameterplan: (tree,action,delflag)
  55.                       P_AVL_NODE *tree;
  56.                       int (*action)();
  57.                       int delflag;
  58.     */
  59.