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