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