hash.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_HASH_H
10 #define SQUID_HASH_H
11 
12 typedef void HASHFREE(void *);
13 typedef int HASHCMP(const void *, const void *);
14 typedef unsigned int HASHHASH(const void *, unsigned int);
15 
16 class hash_link {
17 public:
18  hash_link() : key(nullptr), next(nullptr) {}
19  void *key;
21 };
22 
23 class hash_table {
24 public:
28  unsigned int size;
29  unsigned int current_slot;
31  int count;
32 };
33 
37 SQUIDCEXTERN int hashPrime(int n);
47 SQUIDCEXTERN const char *hashKeyStr(hash_link *);
48 
49 /*
50  * Here are some good prime number choices. It's important not to
51  * choose a prime number that is too close to exact powers of 2.
52  *
53  * HASH_SIZE 103 // prime number < 128
54  * HASH_SIZE 229 // prime number < 256
55  * HASH_SIZE 467 // prime number < 512
56  * HASH_SIZE 977 // prime number < 1024
57  * HASH_SIZE 1979 // prime number < 2048
58  * HASH_SIZE 4019 // prime number < 4096
59  * HASH_SIZE 6037 // prime number < 6144
60  * HASH_SIZE 7951 // prime number < 8192
61  * HASH_SIZE 12149 // prime number < 12288
62  * HASH_SIZE 16231 // prime number < 16384
63  * HASH_SIZE 33493 // prime number < 32768
64  * HASH_SIZE 65357 // prime number < 65536
65  */
66 #define DEFAULT_HASH_SIZE 7951 /* prime number < 8192 */
67 
68 #endif /* SQUID_HASH_H */
69 
SQUIDCEXTERN void hash_first(hash_table *)
Definition: hash.cc:176
SQUIDCEXTERN void hashFreeMemory(hash_table *)
Definition: hash.cc:272
unsigned int HASHHASH(const void *, unsigned int)
Definition: hash.h:14
SQUIDCEXTERN HASHHASH hash_string
Definition: hash.h:45
HASHCMP * cmp
Definition: hash.h:26
#define SQUIDCEXTERN
Definition: squid.h:26
SQUIDCEXTERN void hash_join(hash_table *, hash_link *)
Definition: hash.cc:132
hash_link * next
Definition: hash.h:30
unsigned int current_slot
Definition: hash.h:29
SQUIDCEXTERN hash_link * hash_lookup(hash_table *, const void *)
Definition: hash.cc:147
SQUIDCEXTERN hash_link * hash_get_bucket(hash_table *, unsigned int)
Definition: hash.cc:248
SQUIDCEXTERN hash_table * hash_create(HASHCMP *, int, HASHHASH *)
Definition: hash.cc:109
SQUIDCEXTERN void hashFreeItems(hash_table *, HASHFREE *)
Definition: hash.cc:256
SQUIDCEXTERN const char * hashKeyStr(hash_link *)
Definition: hash.cc:317
SQUIDCEXTERN void hash_last(hash_table *)
Definition: hash.cc:208
hash_link ** buckets
Definition: hash.h:25
void HASHFREE(void *)
Definition: hash.h:12
SQUIDCEXTERN hash_link * hash_next(hash_table *)
Definition: hash.cc:192
HASHHASH * hash
Definition: hash.h:27
SQUIDCEXTERN int hashPrime(int n)
Definition: hash.cc:297
SQUIDCEXTERN void hash_remove_link(hash_table *, hash_link *)
Definition: hash.cc:224
int count
Definition: hash.h:31
SQUIDCEXTERN HASHHASH hash4
Definition: hash.h:46
unsigned int size
Definition: hash.h:28
int HASHCMP(const void *, const void *)
Definition: hash.h:13

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors