Line data Source code
1 : /* Copyright (C) 2002, 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */
2 :
3 : #ifndef __HASHTABLE_PRIVATE_CWC22_H__
4 : #define __HASHTABLE_PRIVATE_CWC22_H__
5 :
6 : #include "hashtable.h"
7 :
8 : /*****************************************************************************/
9 : struct entry
10 : {
11 : void *k, *v;
12 : unsigned int h;
13 : struct entry *next;
14 : };
15 :
16 : struct hashtable {
17 : unsigned int tablelength;
18 : struct entry **table;
19 : unsigned int entrycount;
20 : unsigned int loadlimit;
21 : unsigned int primeindex;
22 : unsigned int (*hashfn) (void *k);
23 : int (*eqfn) (void *k1, void *k2);
24 : };
25 :
26 : /*****************************************************************************/
27 : unsigned int
28 : hash(struct hashtable *h, void *k);
29 :
30 : /*****************************************************************************/
31 : /* indexFor */
32 : static inline unsigned int
33 : indexFor(unsigned int tablelength, unsigned int hashvalue) {
34 0 : return (hashvalue % tablelength);
35 : };
36 :
37 : /* Only works if tablelength == 2^N */
38 : /*static inline unsigned int
39 : indexFor(unsigned int tablelength, unsigned int hashvalue)
40 : {
41 : return (hashvalue & (tablelength - 1u));
42 : }
43 : */
44 :
45 : /*****************************************************************************/
46 : #define freekey(X) free(X)
47 : /*define freekey(X) ; */
48 :
49 :
50 : /*****************************************************************************/
51 :
52 : #endif /* __HASHTABLE_PRIVATE_CWC22_H__*/
53 :
54 : /*
55 : * Copyright (c) 2002, Christopher Clark
56 : * All rights reserved.
57 : *
58 : * Redistribution and use in source and binary forms, with or without
59 : * modification, are permitted provided that the following conditions
60 : * are met:
61 : *
62 : * * Redistributions of source code must retain the above copyright
63 : * notice, this list of conditions and the following disclaimer.
64 : *
65 : * * Redistributions in binary form must reproduce the above copyright
66 : * notice, this list of conditions and the following disclaimer in the
67 : * documentation and/or other materials provided with the distribution.
68 : *
69 : * * Neither the name of the original author; nor the names of any contributors
70 : * may be used to endorse or promote products derived from this software
71 : * without specific prior written permission.
72 : *
73 : *
74 : * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
75 : * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
76 : * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
77 : * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
78 : * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
79 : * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
80 : * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
81 : * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
82 : * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
83 : * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
84 : * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
85 : */
|