home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3149 / avl.h
Encoding:
C/C++ Source or Header  |  1991-03-29  |  2.0 KB  |  77 lines

  1. /**
  2. *  avl.h -- public types and external declarations for avl trees
  3. *
  4. *  Created 03/01/89 by Brad Appleton
  5. *
  6. * ^{Mods:* }
  7. * Fri Jul 14 13:54:12 1989, Rev 1.0, brad(0165)
  8. **/
  9.   
  10. #ifndef AVL_H
  11. #define AVL_H
  12.  
  13. #ifdef __STDC__
  14. # define _P(x)  x
  15. #else
  16. # define _P(x)  ()
  17. #endif
  18.  
  19.        /* definition of traversal type */
  20. typedef  enum  { PREORDER, INORDER, POSTORDER }  VISIT;
  21.   
  22.   
  23.        /* definition of sibling order type */
  24. typedef  enum  { LEFT_TO_RIGHT, RIGHT_TO_LEFT }  SIBLING_ORDER;
  25.   
  26.   
  27.        /* definition of node type */
  28. typedef  enum  { IS_TREE, IS_LBRANCH, IS_RBRANCH, IS_LEAF, IS_NULL }  NODE;
  29.   
  30.   
  31.        /* definition of opaque type for AVL trees */
  32. typedef  void  *AVL_TREE;
  33.   
  34.   
  35. #ifndef NEXTERN
  36.   
  37.      /* Constructor and Destructor functions for AVL trees:
  38.      *          avlfree is a macro for avldispose in the fashion
  39.      *          of free(). It assumes certain default values 
  40.      *          (shown below) for the deallocation function and
  41.      *          for the order in which children are traversed.
  42.      */
  43. extern AVL_TREE     avlinit    _P(( int(*) (), unsigned(*)() ));
  44. extern void         avldispose _P(( AVL_TREE *, void(*) (), SIBLING_ORDER ));
  45. #define avlfree(x)  avldispose _P( &(x), free, LEFT_TO_RIGHT )
  46.     
  47.   
  48.        /* Routine for manipulating/accessing each data item in a tree */
  49. extern void      avlwalk  _P(( AVL_TREE, void(*) (), SIBLING_ORDER ));
  50.   
  51.   
  52.        /* Routine for obtaining the size of an AVL tree */
  53. extern int       avlcount  _P(( AVL_TREE ));
  54.   
  55.   
  56.        /* Routines to search for a given item */
  57. extern void     *avlins  _P(( void *, AVL_TREE ));
  58. extern void     *avldel  _P(( void *, AVL_TREE ));
  59. extern void     *avlfind _P(( void *, AVL_TREE ));
  60.   
  61.   
  62.        /* Routines to search for the minimal item of a tree */
  63. extern void     *avldelmin  _P(( AVL_TREE ));
  64. extern void     *avlfindmin _P(( AVL_TREE ));
  65.   
  66.   
  67.        /* Routines to search for the maximal item of a tree */
  68. extern void     *avldelmax  _P(( AVL_TREE ));
  69. extern void     *avlfindmax _P(( AVL_TREE ));
  70.   
  71. #endif /* NEXTERN */
  72.  
  73. #undef _P
  74. #endif /* AVL_H */
  75.