home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vile-src.zip / vile-8.1 / btree.h < prev    next >
C/C++ Source or Header  |  1998-05-13  |  1KB  |  55 lines

  1. /*
  2.  * $Id: btree.h,v 1.3 1998/05/14 00:46:55 tom Exp $
  3.  *
  4.  * Interface for btree.c
  5.  */
  6. #ifndef BTREE_H
  7. #define BTREE_H 1
  8.  
  9. #ifndef BI_DATA
  10. #define BI_DATA struct _bi_data
  11.      BI_DATA {
  12.     char    *bi_key;    /* the key */
  13.     void    *data;        /* ...associated data */
  14.     };
  15. #endif
  16.  
  17. #define BI_NODE struct _bi_node
  18.     BI_NODE    {
  19.     BI_NODE    *links[2];
  20.     short     balance;    /* holds 0, -1, +1 */
  21.     BI_DATA  value;
  22.     };
  23.  
  24. #define BI_TREE struct _bi_tree
  25.     BI_TREE    {
  26.     BI_NODE*(*allocat) (BI_DATA *a);
  27.     void    (*dealloc) (BI_NODE *a);
  28.     void    (*display) (BI_NODE *a, int level);
  29.     int    depth;
  30.     int    count;
  31.     BI_NODE    head;        /* root data, on end to ease initialization */
  32.     };
  33.  
  34. #define    BI_KEY(p)    (p)->value.bi_key
  35. #define    BI_LEFT(p)    (p)->links[0]
  36. #define    BI_RIGHT(p)    (p)->links[1]
  37.  
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41.  
  42. extern    int     btree_delete(BI_TREE *tree, const char *data);
  43. extern    int     btree_freeup(BI_TREE *tree);
  44. extern    BI_DATA *btree_insert(BI_TREE *tree, BI_DATA *data);
  45. extern    const char **btree_parray(BI_TREE *tree, char *name, unsigned len);
  46. extern    BI_NODE *btree_pmatch(BI_NODE *n, const int mode, const char *name);
  47. extern    void     btree_printf(BI_TREE *tree);
  48. extern    BI_DATA *btree_search(BI_TREE *tree, const char *data);
  49.  
  50. #ifdef __cplusplus
  51. }
  52. #endif
  53.  
  54. #endif /* BTREE_H */
  55.