author | sandman <sandman> | 2002-04-13 00:47:20 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-04-13 00:47:20 (UTC) |
commit | 98a1e3f36567639344f12932b629e526a8783aa8 (patch) (unidiff) | |
tree | 0433d296857faceeafc54f7deabddb621f45a933 /noncore/unsupported/qpdf/goo/GHash.h | |
parent | 7e31b1fba119f69929d6744d7295555ff1727f4f (diff) | |
download | opie-98a1e3f36567639344f12932b629e526a8783aa8.zip opie-98a1e3f36567639344f12932b629e526a8783aa8.tar.gz opie-98a1e3f36567639344f12932b629e526a8783aa8.tar.bz2 |
CVS import of QPdf
Diffstat (limited to 'noncore/unsupported/qpdf/goo/GHash.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/qpdf/goo/GHash.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/noncore/unsupported/qpdf/goo/GHash.h b/noncore/unsupported/qpdf/goo/GHash.h new file mode 100644 index 0000000..be1e573 --- a/dev/null +++ b/noncore/unsupported/qpdf/goo/GHash.h | |||
@@ -0,0 +1,67 @@ | |||
1 | //======================================================================== | ||
2 | // | ||
3 | // GHash.h | ||
4 | // | ||
5 | // Copyright 2001 Derek B. Noonburg | ||
6 | // | ||
7 | //======================================================================== | ||
8 | |||
9 | #ifndef GHASH_H | ||
10 | #define GHASH_H | ||
11 | |||
12 | #ifdef __GNUC__ | ||
13 | #pragma interface | ||
14 | #endif | ||
15 | |||
16 | #include "gtypes.h" | ||
17 | |||
18 | class GString; | ||
19 | struct GHashBucket; | ||
20 | struct GHashIter; | ||
21 | |||
22 | //------------------------------------------------------------------------ | ||
23 | |||
24 | class GHash { | ||
25 | public: | ||
26 | |||
27 | GHash(GBool deleteKeysA = gFalse); | ||
28 | ~GHash(); | ||
29 | void add(GString *key, void *val); | ||
30 | void *lookup(GString *key); | ||
31 | void *lookup(char *key); | ||
32 | void *remove(GString *key); | ||
33 | void *remove(char *key); | ||
34 | int getLength() { return len; } | ||
35 | void startIter(GHashIter **iter); | ||
36 | GBool getNext(GHashIter **iter, GString **key, void **val); | ||
37 | void killIter(GHashIter **iter); | ||
38 | |||
39 | private: | ||
40 | |||
41 | GHashBucket *find(GString *key, int *h); | ||
42 | GHashBucket *find(char *key, int *h); | ||
43 | int hash(GString *key); | ||
44 | int hash(char *key); | ||
45 | |||
46 | GBool deleteKeys; // set if key strings should be deleted | ||
47 | int size; // number of buckets | ||
48 | int len; // number of entries | ||
49 | GHashBucket **tab; | ||
50 | }; | ||
51 | |||
52 | #define deleteGHash(hash, T) \ | ||
53 | do { \ | ||
54 | GHash *_hash = (hash); \ | ||
55 | { \ | ||
56 | GHashIter *_iter; \ | ||
57 | GString *_key; \ | ||
58 | void *_p; \ | ||
59 | _hash->startIter(&_iter); \ | ||
60 | while (_hash->getNext(&_iter, &_key, &_p)) { \ | ||
61 | delete (T*)_p; \ | ||
62 | } \ | ||
63 | delete _hash; \ | ||
64 | } \ | ||
65 | } while(0) | ||
66 | |||
67 | #endif | ||