CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
hash64.h
Go to the documentation of this file.
1 #ifndef CondCommon_Hash64_h
2 #define CondCommon_Hash64_h
3 
4 namespace cond {
5 
6  /*
7  --------------------------------------------------------------------
8  lookup8.c, by Bob Jenkins, January 4 1997, Public Domain.
9  hash(), hash2(), hash3, and mix() are externally useful functions.
10  Routines to test the hash are included if SELF_TEST is defined.
11  You can use this free for any purpose. It has no warranty.
12  --------------------------------------------------------------------
13  */
14 
15 
16  /*
17  --------------------------------------------------------------------
18  hash() -- hash a variable-length key into a 64-bit value
19  k : the key (the unaligned variable-length array of bytes)
20  len : the length of the key, counting by bytes
21  level : can be any 8-byte value
22  Returns a 64-bit value. Every bit of the key affects every bit of
23  the return value. No funnels. Every 1-bit and 2-bit delta achieves
24  avalanche. About 41+5len instructions.
25 
26  The best hash table sizes are powers of 2. There is no need to do
27  mod a prime (mod is sooo slow!). If you need less than 64 bits,
28  use a bitmask. For example, if you need only 10 bits, do
29  h = (h & hashmask(10));
30  In which case, the hash table should have hashsize(10) elements.
31 
32  If you are hashing n strings (ub1 **)k, do it like this:
33  for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h);
34 
35  By Bob Jenkins, Jan 4 1997. bob_jenkins@burtleburtle.net. You may
36  use this code any way you wish, private, educational, or commercial,
37  but I would appreciate if you give me credit.
38 
39  See http://burtleburtle.net/bob/hash/evahash.html
40  Use for hash table lookup, or anything where one collision in 2^^64
41  is acceptable. Do NOT use for cryptographic purposes.
42  --------------------------------------------------------------------
43  */
44  /*
45  --------------------------------------------------------------------
46  This is identical to hash() on little-endian machines, and it is much
47  faster than hash(), but a little slower than hash2(), and it requires
48  -- that all your machines be little-endian, for example all Intel x86
49  chips or all VAXen. It gives wrong results on big-endian machines.
50  --------------------------------------------------------------------
51  */
52 
53  unsigned long long hash64( unsigned char * k, unsigned long long length, unsigned long long level);
54 
55 
56 }
57 #endif
unsigned long long hash64(unsigned char *k, unsigned long long length, unsigned long long level)
Definition: hash64.cc:45
tuple level
Definition: testEve_cfg.py:34