]>
Commit | Line | Data |
---|---|---|
28bf4b0b | 1 | /* |
2 | ** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2001. | |
3 | ** See ../LICENSE for license information. | |
4 | ** | |
5 | */ | |
6 | /* | |
7 | ** cstringTable.h | |
8 | */ | |
9 | ||
10 | # ifndef CSTRINGTABLE_H | |
11 | # define CSTRINGTABLE_H | |
12 | ||
13 | /*@constant int HBUCKET_BASESIZE; @*/ | |
14 | # define HBUCKET_BASESIZE 2 | |
15 | ||
16 | /*@constant int HBUCKET_DNE; @*/ | |
17 | # define HBUCKET_DNE NOT_FOUND | |
18 | ||
19 | /* in forwardTypes: | |
20 | abst_typedef null struct _cstringTable *cstringTable; | |
21 | */ | |
22 | ||
23 | /*@private@*/ typedef struct | |
24 | { | |
25 | /*@only@*/ cstring key; | |
26 | int val; | |
27 | } *hentry; | |
28 | ||
29 | /*@private@*/ typedef /*@only@*/ hentry o_hentry; | |
30 | ||
31 | typedef /*@null@*/ struct | |
32 | { | |
33 | int size; | |
34 | int nspace; | |
35 | /*@only@*/ o_hentry *entries; | |
36 | } *hbucket; | |
37 | ||
38 | typedef /*@only@*/ hbucket o_hbucket; | |
39 | ||
40 | struct s_cstringTable | |
41 | { | |
42 | int size; | |
43 | int nentries; | |
44 | /*@only@*/ o_hbucket *buckets; | |
45 | } ; | |
46 | ||
47 | ||
48 | /*@constant null cstringTable cstringTable_undefined; @*/ | |
49 | # define cstringTable_undefined ((cstringTable) NULL) | |
50 | ||
51 | extern /*@falsenull@*/ bool cstringTable_isDefined(cstringTable) /*@*/ ; | |
52 | # define cstringTable_isDefined(p_h) ((p_h) != cstringTable_undefined) | |
53 | ||
54 | extern /*@truenull@*/ /*@unused@*/ bool cstringTable_isUndefined(cstringTable) /*@*/ ; | |
55 | # define cstringTable_isUndefined(p_h) ((p_h) == cstringTable_undefined) | |
56 | ||
57 | extern /*@only@*/ cstringTable cstringTable_create(int p_size) /*@*/ ; | |
58 | extern void cstringTable_insert (cstringTable p_h, | |
59 | /*@only@*/ cstring p_key, | |
60 | int p_value) /*@modifies p_h@*/ ; | |
61 | ||
62 | extern int cstringTable_lookup (cstringTable p_h, cstring p_key); | |
63 | extern /*@unused@*/ /*@only@*/ cstring cstringTable_stats(cstringTable p_h); | |
64 | extern void cstringTable_free (/*@only@*/ cstringTable p_h); | |
65 | extern void cstringTable_remove (cstringTable p_h, cstring p_key) /*@modifies p_h@*/ ; | |
66 | ||
67 | extern /*@unused@*/ cstring cstringTable_unparse (cstringTable) /*@*/ ; | |
68 | ||
69 | extern /*@unused@*/ void cstringTable_update (cstringTable p_h, cstring p_key, int p_newval) /*@modifies p_h@*/ ; | |
70 | ||
71 | extern void | |
72 | cstringTable_replaceKey (cstringTable p_h, cstring p_oldkey, | |
73 | /*@only@*/ cstring p_newkey); | |
74 | ||
75 | # else | |
76 | # error "Multiple include" | |
77 | # endif | |
78 | ||
79 | ||
80 | ||
81 | ||
82 | ||
83 | ||
84 | ||
85 | ||
86 | ||
87 | ||
88 | ||
89 | ||
90 |