home *** CD-ROM | disk | FTP | other *** search
- /* avl.h Definitions for avl routines
-
- Copyright 1988 Zinn Computer Company
- by Mark E. Mallett
- All Rights Reserved
-
- This software may be used at will, provided that all credits
- and style be left in place, and that its distribution is not
- restricted. Bug fixes and improvements are welcomed, please
- send these back to me at mem@zinn.MV.COM
- */
-
- #ifndef H_AVL /* Prevent multiple inclusions */
- #define H_AVL
-
- /*--------------------------------------------------------------
- * rlp900624 -- Support for Lattice-style prototypes
- * If MSDOS, I assume Microsoft C compiler for DOS and OS/2
- * If Lattice, I assume Lattice C compiler for Amiga
- *--------------------------------------------------------------
- */
-
- #ifndef __ARGS
- #if defined(MSDOS) || defined(LATTICE)
- #define __ARGS(a) a
- #else
- #define __ARGS(a) ()
- #endif
- #endif
-
- #ifndef TRUE /* Same old jazz */
- #define TRUE 1
- #define FALSE 0
- #endif TRUE
-
- #ifndef NULL
- #define NULL ((char *)0)
- #endif NULL
-
- #ifndef NUL
- #define NUL '\0'
- #endif NUL
-
- /*-------------------------------------------
- * rlp900624 -- added typedefs and prototypes
- *-------------------------------------------
- */
-
- typedef struct _AVLNODE AVLNODE;
- typedef struct _AVLTREE AVLTREE;
-
- typedef int (*PFNCMPRTC) __ARGS((void *, AVLNODE *));
- typedef AVLNODE *(*PFNMKNODE) __ARGS((AVLTREE *, void *, void *, AVLNODE *));
- typedef int (*PFNRMNODE) __ARGS((AVLTREE *, AVLNODE *));
-
- AVLNODE *avlfind __ARGS(( AVLTREE *treeP, void *keyP ));
- int avlinsert __ARGS(( AVLTREE *treeP, void *keyP, void *dataP ));
- int avldelete __ARGS(( AVLTREE *treeP, void *keyP ));
-
- /* Structures */
-
- /* Structure of an avl tree node. Note that this node is meant to
- be used as a header or component of an application-specific structure,
- since there is no key or data information present in the avlnode
- structure.
- */
-
- typedef /* A node in an AVL tree */
- struct _AVLNODE {
- AVLNODE *n_leftP; /* Ptr to left subtree */
- AVLNODE *n_rightP; /* Ptr to right subtree */
- int n_balance; /* Balance count */
- } AVLNODE;
-
- typedef /* The header for an AVL tree */
- struct _AVLTREE {
- /* Tree parameters */
- AVLNODE *t_rootP; /* Ptr to root node */
-
- /* Handler functions for the tree */
- /* rlp900622 -- use my typedefs for these function ptrs */
-
- PFNCMPRTC t_cmprtc; /* int (*t_cmprtc)(); Compare two keys */
- PFNMKNODE t_mknode; /* AVLNODE *(*t_mknode)(); Node maker */
- PFNRMNODE t_rmnode; /* int (*t_rmnode)(); Node destroyer */
- } AVLTREE;
-
- #endif H_AVL;
-