home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gnurx.zip / rx / rxhash.h < prev    next >
C/C++ Source or Header  |  1995-12-31  |  3KB  |  119 lines

  1. /* classes: h_files */
  2.  
  3. #ifndef RXHASHH
  4. #define RXHASHH
  5. /***********************************************************
  6.  
  7. Copyright 1995 by Tom Lord
  8.  
  9.                         All Rights Reserved
  10.  
  11. Permission to use, copy, modify, and distribute this software and its 
  12. documentation for any purpose and without fee is hereby granted, 
  13. provided that the above copyright notice appear in all copies and that
  14. both that copyright notice and this permission notice appear in 
  15. supporting documentation, and that the name of the copyright holder not be
  16. used in advertising or publicity pertaining to distribution of the
  17. software without specific, written prior permission.  
  18.  
  19. Tom Lord DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  20. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  21. EVENT SHALL TOM LORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  22. CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  23. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  24. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  25. PERFORMANCE OF THIS SOFTWARE.
  26.  
  27. ******************************************************************/
  28.  
  29.  
  30.  
  31. /*
  32.  * Tom Lord (lord@cygnus.com, lord@gnu.ai.mit.edu)
  33.  */
  34.  
  35.  
  36. #include "rxbitset.h"
  37.  
  38. /* giant inflatable hash trees */
  39.  
  40. struct rx_hash_item
  41. {
  42.   struct rx_hash_item * next_same_hash;
  43.   struct rx_hash * table;
  44.   unsigned long hash;
  45.   void * data;
  46.   void * binding;
  47. };
  48.  
  49. struct rx_hash
  50. {
  51.   struct rx_hash * parent;
  52.   int refs;
  53.   RX_subset nested_p;
  54.   void ** children[16];
  55. };
  56.  
  57. struct rx_hash_rules;
  58.  
  59. /* rx_hash_eq should work like the == operator. */
  60.  
  61. #ifdef __STDC__
  62. typedef int (*rx_hash_eq)(void *, void *);
  63. typedef struct rx_hash * (*rx_alloc_hash)(struct rx_hash_rules *);
  64. typedef void (*rx_free_hash)(struct rx_hash *,
  65.                 struct rx_hash_rules *);
  66. typedef struct rx_hash_item * (*rx_alloc_hash_item)(struct rx_hash_rules *,
  67.                             void *);
  68. typedef void (*rx_free_hash_item)(struct rx_hash_item *,
  69.                  struct rx_hash_rules *);
  70. typedef void (*rx_hash_freefn) (struct rx_hash_item * it);
  71. #else
  72. typedef int (*rx_hash_eq)();
  73. typedef struct rx_hash * (*rx_alloc_hash)();
  74. typedef void (*rx_free_hash)();
  75. typedef struct rx_hash_item * (*rx_alloc_hash_item)();
  76. typedef void (*rx_free_hash_item)();
  77. typedef void (*rx_hash_freefn) ();
  78. #endif
  79.  
  80. struct rx_hash_rules
  81. {
  82.   rx_hash_eq eq;
  83.   rx_alloc_hash hash_alloc;
  84.   rx_free_hash free_hash;
  85.   rx_alloc_hash_item hash_item_alloc;
  86.   rx_free_hash_item free_hash_item;
  87. };
  88.  
  89.  
  90. #ifdef __STDC__
  91. extern struct rx_hash_item * rx_hash_find (struct rx_hash * table,
  92.                            unsigned long hash,
  93.                            void * value,
  94.                            struct rx_hash_rules * rules);
  95. extern struct rx_hash_item * rx_hash_store (struct rx_hash * table,
  96.                             unsigned long hash,
  97.                             void * value,
  98.                             struct rx_hash_rules * rules);
  99. extern void rx_hash_free (struct rx_hash_item * it, struct rx_hash_rules * rules);
  100. extern void rx_free_hash_table (struct rx_hash * tab, rx_hash_freefn freefn,
  101.                     struct rx_hash_rules * rules);
  102. extern int rx_count_hash_nodes (struct rx_hash * st);
  103.  
  104. #else /* STDC */
  105. extern struct rx_hash_item * rx_hash_find ();
  106. extern struct rx_hash_item * rx_hash_store ();
  107. extern void rx_hash_free ();
  108. extern void rx_free_hash_table ();
  109. extern int rx_count_hash_nodes ();
  110.  
  111. #endif /* STDC */
  112.  
  113.  
  114.  
  115.  
  116.  
  117. #endif  /* RXHASHH */
  118.  
  119.