]> git.ipfire.org Git - thirdparty/squid.git/blame - include/hash.h
Cleanup: zap CVS Id tags
[thirdparty/squid.git] / include / hash.h
CommitLineData
0e2cd867 1/*
262a0e14 2 * $Id$
0e2cd867 3 */
b5638623 4#ifndef SQUID_HASH_H
5#define SQUID_HASH_H
6
e1f7507e
AJ
7#include "config.h"
8
f52a7d75 9typedef void HASHFREE(void *);
10typedef int HASHCMP(const void *, const void *);
11typedef unsigned int HASHHASH(const void *, unsigned int);
12typedef struct _hash_link hash_link;
13typedef struct _hash_table hash_table;
14
15struct _hash_link {
186477c1 16 void *key;
f52a7d75 17 hash_link *next;
18};
19
20struct _hash_table {
21 hash_link **buckets;
22 HASHCMP *cmp;
23 HASHHASH *hash;
24 unsigned int size;
25 unsigned int current_slot;
26 hash_link *next;
27 int count;
28};
29
e6ccf245 30SQUIDCEXTERN hash_table *hash_create(HASHCMP *, int, HASHHASH *);
31SQUIDCEXTERN void hash_join(hash_table *, hash_link *);
32SQUIDCEXTERN void hash_remove_link(hash_table *, hash_link *);
33SQUIDCEXTERN int hashPrime(int n);
4a8b20e8 34SQUIDCEXTERN hash_link *hash_lookup(hash_table *, const void *);
e6ccf245 35SQUIDCEXTERN void hash_first(hash_table *);
4a8b20e8 36SQUIDCEXTERN hash_link *hash_next(hash_table *);
e6ccf245 37SQUIDCEXTERN void hash_last(hash_table *);
38SQUIDCEXTERN hash_link *hash_get_bucket(hash_table *, unsigned int);
39SQUIDCEXTERN void hashFreeMemory(hash_table *);
40SQUIDCEXTERN void hashFreeItems(hash_table *, HASHFREE *);
41SQUIDCEXTERN HASHHASH hash_string;
42SQUIDCEXTERN HASHHASH hash4;
43SQUIDCEXTERN const char *hashKeyStr(hash_link *);
f52a7d75 44
45/*
46 * Here are some good prime number choices. It's important not to
47 * choose a prime number that is too close to exact powers of 2.
48 *
49 * HASH_SIZE 103 // prime number < 128
50 * HASH_SIZE 229 // prime number < 256
51 * HASH_SIZE 467 // prime number < 512
52 * HASH_SIZE 977 // prime number < 1024
53 * HASH_SIZE 1979 // prime number < 2048
54 * HASH_SIZE 4019 // prime number < 4096
55 * HASH_SIZE 6037 // prime number < 6144
56 * HASH_SIZE 7951 // prime number < 8192
57 * HASH_SIZE 12149 // prime number < 12288
58 * HASH_SIZE 16231 // prime number < 16384
59 * HASH_SIZE 33493 // prime number < 32768
60 * HASH_SIZE 65357 // prime number < 65536
61 */
186477c1 62#define DEFAULT_HASH_SIZE 7951 /* prime number < 8192 */
b5638623 63
64#endif /* SQUID_HASH_H */