root/src/include/private/hashtable_private.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. indexFor

   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 #ifdef __cplusplus
   9 extern "C" {
  10 #endif
  11 /*****************************************************************************/
  12 
  13 struct entry
  14 {
  15     void *k, *v;
  16     unsigned int h;
  17         hashtable_flag_t flags;
  18     struct entry *next;
  19 };
  20 
  21 struct hashtable_iterator {
  22         unsigned int pos;
  23         struct entry *e;
  24         struct hashtable *h;
  25 };
  26 
  27 struct hashtable {
  28     unsigned int tablelength;
  29     struct entry **table;
  30     unsigned int entrycount;
  31     unsigned int loadlimit;
  32     unsigned int primeindex;
  33     unsigned int (*hashfn) (void *k);
  34     int (*eqfn) (void *k1, void *k2);
  35         struct hashtable_iterator iterator;
  36 };
  37 
  38 /*****************************************************************************/
  39 unsigned int
  40 hash(struct hashtable *h, void *k);
  41 
  42 /*****************************************************************************/
  43 /* indexFor */
  44 static __inline__ unsigned int
  45 indexFor(unsigned int tablelength, unsigned int hashvalue) {
  46     return (hashvalue % tablelength);
  47 }
  48 
  49 /* Only works if tablelength == 2^N */
  50 /*static inline unsigned int
  51   indexFor(unsigned int tablelength, unsigned int hashvalue)
  52   {
  53   return (hashvalue & (tablelength - 1u));
  54   }
  55 */
  56 
  57 /*****************************************************************************/
  58 #define freekey(X) free(X)
  59 /*define freekey(X) ; */
  60 
  61 #ifdef __cplusplus
  62 }
  63 #endif
  64 
  65 /*****************************************************************************/
  66 
  67 #endif /* __HASHTABLE_PRIVATE_CWC22_H__*/
  68 
  69 /*
  70  * Copyright (c) 2002, Christopher Clark
  71  * All rights reserved.
  72  * 
  73  * Redistribution and use in source and binary forms, with or without
  74  * modification, are permitted provided that the following conditions
  75  * are met:
  76  * 
  77  * * Redistributions of source code must retain the above copyright
  78  * notice, this list of conditions and the following disclaimer.
  79  * 
  80  * * Redistributions in binary form must reproduce the above copyright
  81  * notice, this list of conditions and the following disclaimer in the
  82  * documentation and/or other materials provided with the distribution.
  83  * 
  84  * * Neither the name of the original author; nor the names of any contributors
  85  * may be used to endorse or promote products derived from this software
  86  * without specific prior written permission.
  87  * 
  88  * 
  89  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  90  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  91  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  92  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
  93  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  94  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  95  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  96  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  97  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  98  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  99  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 100  */
 101 /* For Emacs:
 102  * Local Variables:
 103  * mode:c
 104  * indent-tabs-mode:t
 105  * tab-width:4
 106  * c-basic-offset:4
 107  * End:
 108  * For VIM:
 109  * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
 110  */

/* [<][>][^][v][top][bottom][index][help] */