]>
Commit | Line | Data |
---|---|---|
1 | /* classes: h_files */ | |
2 | ||
3 | #ifndef RXHASHH | |
4 | #define RXHASHH | |
5 | /* Copyright (C) 1995, 1996 Tom Lord | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU Library General Public License as published by | |
9 | * the Free Software Foundation; either version 2, or (at your option) | |
10 | * any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU Library General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU Library General Public License | |
18 | * along with this software; see the file COPYING. If not, write to | |
19 | * the Free Software Foundation, 59 Temple Place - Suite 330, | |
20 | * Boston, MA 02111-1307, USA. | |
21 | */ | |
22 | ||
23 | ||
24 | \f | |
25 | /* | |
26 | * Tom Lord (lord@cygnus.com, lord@gnu.ai.mit.edu) | |
27 | */ | |
28 | \f | |
29 | ||
30 | #include "rxbitset.h" | |
31 | ||
32 | /* giant inflatable hash trees */ | |
33 | ||
34 | struct rx_hash_item | |
35 | { | |
36 | struct rx_hash_item * next_same_hash; | |
37 | struct rx_hash * table; | |
38 | unsigned long hash; | |
39 | void * data; | |
40 | void * binding; | |
41 | }; | |
42 | ||
43 | struct rx_hash | |
44 | { | |
45 | struct rx_hash * parent; | |
46 | int refs; | |
47 | RX_subset nested_p; | |
48 | void ** children[16]; | |
49 | }; | |
50 | ||
51 | struct rx_hash_rules; | |
52 | ||
53 | /* rx_hash_eq should work like the == operator. */ | |
54 | ||
55 | #ifdef __STDC__ | |
56 | typedef int (*rx_hash_eq)(void *, void *); | |
57 | typedef struct rx_hash * (*rx_alloc_hash)(struct rx_hash_rules *); | |
58 | typedef void (*rx_free_hash)(struct rx_hash *, | |
59 | struct rx_hash_rules *); | |
60 | typedef struct rx_hash_item * (*rx_alloc_hash_item)(struct rx_hash_rules *, | |
61 | void *); | |
62 | typedef void (*rx_free_hash_item)(struct rx_hash_item *, | |
63 | struct rx_hash_rules *); | |
64 | typedef void (*rx_hash_freefn) (struct rx_hash_item * it); | |
65 | #else | |
66 | typedef int (*rx_hash_eq)(); | |
67 | typedef struct rx_hash * (*rx_alloc_hash)(); | |
68 | typedef void (*rx_free_hash)(); | |
69 | typedef struct rx_hash_item * (*rx_alloc_hash_item)(); | |
70 | typedef void (*rx_free_hash_item)(); | |
71 | typedef void (*rx_hash_freefn) (); | |
72 | #endif | |
73 | ||
74 | struct rx_hash_rules | |
75 | { | |
76 | rx_hash_eq eq; | |
77 | rx_alloc_hash hash_alloc; | |
78 | rx_free_hash free_hash; | |
79 | rx_alloc_hash_item hash_item_alloc; | |
80 | rx_free_hash_item free_hash_item; | |
81 | }; | |
82 | ||
83 | \f | |
84 | #ifdef __STDC__ | |
85 | extern struct rx_hash_item * rx_hash_find (struct rx_hash * table, | |
86 | unsigned long hash, | |
87 | void * value, | |
88 | struct rx_hash_rules * rules); | |
89 | extern struct rx_hash_item * rx_hash_store (struct rx_hash * table, | |
90 | unsigned long hash, | |
91 | void * value, | |
92 | struct rx_hash_rules * rules); | |
93 | extern void rx_hash_free (struct rx_hash_item * it, struct rx_hash_rules * rules); | |
94 | extern void rx_free_hash_table (struct rx_hash * tab, rx_hash_freefn freefn, | |
95 | struct rx_hash_rules * rules); | |
96 | extern int rx_count_hash_nodes (struct rx_hash * st); | |
97 | ||
98 | #else /* STDC */ | |
99 | extern struct rx_hash_item * rx_hash_find (); | |
100 | extern struct rx_hash_item * rx_hash_store (); | |
101 | extern void rx_hash_free (); | |
102 | extern void rx_free_hash_table (); | |
103 | extern int rx_count_hash_nodes (); | |
104 | ||
105 | #endif /* STDC */ | |
106 | ||
107 | ||
108 | ||
109 | ||
110 | ||
111 | #endif /* RXHASHH */ | |
112 |