~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
cvs/emstar/routing/geo-linkstate/hash.h


  1 /*
  2  *
  3  * Copyright (c) 2003 The Regents of the University of California.  All 
  4  * rights reserved.
  5  *
  6  * Redistribution and use in source and binary forms, with or without
  7  * modification, are permitted provided that the following conditions
  8  * are met:
  9  *
 10  * - Redistributions of source code must retain the above copyright
 11  *   notice, this list of conditions and the following disclaimer.
 12  *
 13  * - Neither the name of the University nor the names of its
 14  *   contributors may be used to endorse or promote products derived
 15  *   from this software without specific prior written permission.
 16  *
 17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
 18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 19  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 20  * PARTICULAR  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
 21  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 25  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28  *
 29  */
 30  
 31 
 32 /* This is a header file for a hash function facility.  */
 33 #ifndef HASH_H_
 34 #define HASH_H
 35 
 36 #ifdef __cplusplus
 37 extern "C"
 38 {
 39 #endif
 40 
 41 /* utility functions needed by glib */
 42 
 43 /* given a pointer to the key (assuming that pointer is to the unsigned long)
 44  * produce an unsigned int output */
 45 guint hash_u32(gconstpointer key);
 46 
 47 /* given a pointer to the key (assuming that pointer is to udp_info structure)
 48  * produce an unsigned int output */
 49 guint hash_udp(gconstpointer key);
 50 
 51 /* given a pointer to the key (assuming the key is a pointer to a geo_info 
 52  * structure) produce an unsigned int output */
 53 guint hash_geoinfo(gconstpointer key);
 54 
 55 /* function used by GHashTable to compare our structures.
 56  * (works for both neighbor lists and global tables as long as we can rely on id
 57  * being the first field in either structure */
 58 gboolean hash_compare_u32(gconstpointer a, gconstpointer b);
 59 
 60 /* function used by GHashTable to compare our structures.  Assumes that the
 61  * things that are being compared are both pointers to 'struct udp_info' */
 62 gboolean hash_compare_udp(gconstpointer a, gconstpointer b);
 63 
 64 /* function used by GHashTable to compare our structures.  Assumes that the
 65  * things that are being compared are both pointers to 'struct geo_info' */
 66 gboolean hash_compare_geoinfo(gconstpointer a, gconstpointer b);
 67 
 68 /*
 69  * Originally, it seems the idea came from Robert Jenkins
 70  * (http://www.burtleburtle.net/bob/hash/doobs.html), but his version is much
 71  * more suitable for hashing longer keys. His hash function consists of multiple
 72  * rounds of 'mixing' + other magic. 
 73  *
 74  * Thomas Wang then extended the idea and applied it to integers.
 75  * (http://www.concentric.net/~Ttwang/tech/inthash.htm). 
 76  * He provided a hash function for integers. He further suggests that multiple
 77  * rounds of application of this function is desirable for better results, at
 78  * the price of performance. (but we're not using that at all)
 79  */
 80 /* original function signature: int inthash(int key) */
 81 unsigned long int twang_hash(unsigned long int key);
 82 
 83 /* FIXME: test for now */
 84 void key_destroy_func(gpointer data);
 85 void value_destroy_func(gpointer data);
 86 
 87 #ifdef __cplusplus
 88 }
 89 #endif
 90 
 91 #endif  /* HASH_H_ */
 92 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.