AVL tree library (error in previous posting)

Brad Appleton brad at SSD.CSD.HARRIS.COM
Fri Mar 29 07:23:59 AEST 1991


I tried to hack up avl.h for ANSI-C at the last minute in my previous
posting. I did not do it correctly. Here is the corrected version of
avl.h (sorry about that). This should replace the previous version of
avl.h.


#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  avl.h
# Wrapped by brad at hcx2 on Thu Mar 28 16:20:18 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'avl.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'avl.h'\"
else
echo shar: Extracting \"'avl.h'\" \(2097 characters\)
sed "s/^X//" >'avl.h' <<'END_OF_FILE'
X/**
X*  avl.h -- public types and external declarations for avl trees
X*
X*  Created 03/01/89 by Brad Appleton
X*
X* ^{Mods:* }
X* 
X* Fri Jul 14 13:54:12 1989, Rev 1.0, brad(0165)
X* 
X**/
X  
X#ifndef AVL_H
X#define AVL_H
X
X#ifdef __STDC__
X# define _P(x)  x
X#else
X# define _P(x)  ()
X#endif
X
X       /* definition of traversal type */
Xtypedef  enum  { PREORDER, INORDER, POSTORDER }  VISIT;
X  
X  
X       /* definition of sibling order type */
Xtypedef  enum  { LEFT_TO_RIGHT, RIGHT_TO_LEFT }  SIBLING_ORDER;
X  
X  
X       /* definition of node type */
Xtypedef  enum  { IS_TREE, IS_LBRANCH, IS_RBRANCH, IS_LEAF, IS_NULL }  NODE;
X  
X  
X       /* definition of opaque type for AVL trees */
Xtypedef  void  *AVL_TREE;
X  
X  
X#ifndef NEXTERN
X  
X     /* Constructor and Destructor functions for AVL trees:
X     *          avlfree is a macro for avldispose in the fashion
X     *          of free(). It assumes certain default values 
X     *          (shown below) for the deallocation function and
X     *          for the order in which children are traversed.
X     */
Xextern AVL_TREE     avlinit    _P(( int(*) (), unsigned(*)() ));
Xextern void         avldispose _P(( AVL_TREE *, void(*) (), SIBLING_ORDER ));
X#define avlfree(x)  avldispose _P( &(x), free, LEFT_TO_RIGHT )
X    
X  
X       /* Routine for manipulating/accessing each data item in a tree */
Xextern void      avlwalk  _P(( AVL_TREE, void(*) (), SIBLING_ORDER ));
X  
X  
X       /* Routine for obtaining the size of an AVL tree */
Xextern int       avlcount  _P(( AVL_TREE ));
X  
X  
X       /* Routines to search for a given item */
Xextern void     *avlins  _P(( void *, AVL_TREE ));
Xextern void     *avldel  _P(( void *, AVL_TREE ));
Xextern void     *avlfind _P(( void *, AVL_TREE ));
X  
X  
X       /* Routines to search for the minimal item of a tree */
Xextern void     *avldelmin  _P(( AVL_TREE ));
Xextern void     *avlfindmin _P(( AVL_TREE ));
X  
X  
X       /* Routines to search for the maximal item of a tree */
Xextern void     *avldelmax  _P(( AVL_TREE ));
Xextern void     *avlfindmax _P(( AVL_TREE ));
X  
X#endif /* NEXTERN */
X
X#undef _P
X#endif /* AVL_H */
END_OF_FILE
if test 2097 -ne `wc -c <'avl.h'`; then
    echo shar: \"'avl.h'\" unpacked with wrong size!
fi
# end of 'avl.h'
fi
echo shar: End of shell archive.
exit 0
______________________ "And miles to go before I sleep." ______________________
 Brad Appleton           brad at ssd.csd.harris.com       Harris Computer Systems
                             uunet!hcx1!brad           Fort Lauderdale, FL USA
~~~~~~~~~~~~~~~~~~~~ Disclaimer: I said it, not my company! ~~~~~~~~~~~~~~~~~~~



More information about the Alt.sources mailing list