Lumiera  0.pre.03
»edit your freedom«
hash-value.h
Go to the documentation of this file.
1 /*
2  HASH-VALUE.hpp - collection of tools and definitions for working with hashes
3 
4  Copyright (C) Lumiera.org
5  2012, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
35 #ifndef LIB_HASH_VALUE_H
36 #define LIB_HASH_VALUE_H
37 
38 #include <stdlib.h>
39 
40 
45 typedef unsigned char lumiera_uid[16];
46 typedef lumiera_uid* LumieraUid;
47 
48 
49 
50 #ifdef __cplusplus /* =========== C++ definitions ====================== */
51 
52 
53 namespace lib {
54 
56  typedef size_t HashVal;
57 
59  typedef lumiera_uid* LUID;
60 
61 
62 
63  namespace hash {
64 
70  inline void
71  combine (size_t & combinedHash, size_t additionalHash)
72  {
73  combinedHash ^= additionalHash
74  + 0x9e3779b9
75  + (combinedHash<<6)
76  + (combinedHash>>2);
77  }
81  /*
82 // Don't define 64-bit hash combine on platforms without 64 bit integers,
83 // and also not for 32-bit gcc as it warns about the 64-bit constant.
84 #if !defined(BOOST_NO_INT64_T) && \
85  !(defined(__GNUC__) && ULONG_MAX == 0xffffffff)
86 
87  inline void hash_combine_impl(boost::uint64_t& h,
88  boost::uint64_t k)
89  {
90  const boost::uint64_t m = UINT64_C(0xc6a4a7935bd1e995);
91  const int r = 47;
92 
93  k *= m;
94  k ^= k >> r;
95  k *= m;
96 
97  h ^= k;
98  h *= m;
99 
100  // Completely arbitrary number, to prevent 0's
101  // from hashing to 0.
102  h += 0xe6546b64;
103  }
104 
105 #endif // BOOST_NO_INT64_T
106  */
107  //
108  // WIP more utils to come here....
109  }
110 
111 
112 
113 } // namespace lib
114 #endif /* C++ */
115 #endif /*LIB_HASH_UTIL_H*/
lumiera_uid * LUID
a Lumiera UID
Definition: hash-value.h:59
void combine(size_t &combinedHash, size_t additionalHash)
meld the additional hash value into the given base hash value.
Definition: hash-value.h:71
Implementation namespace for support and library code.
size_t HashVal
a STL compatible hash value
Definition: hash-value.h:56
unsigned char lumiera_uid[16]
storage for a Lumiera unique ID, based on a 128bit random number
Definition: hash-value.h:45