HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SYS_Hash.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: SYS_Hash.h (SYS Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __SYS_Hash__
12 #define __SYS_Hash__
13 
14 #include "SYS_API.h"
15 #include "SYS_Math.h"
16 #include <hboost/functional/hash.hpp>
17 
18 /// Define the type for hash values
19 typedef std::size_t SYS_HashType;
20 
21 template <typename VALUE_TYPE>
22 static inline SYS_HashType
23 SYShash(const VALUE_TYPE &value)
24 {
25  return hboost::hash<VALUE_TYPE>()(value);
26 }
27 
28 /// Combine two hash values. This will compute the hash of the @c VALUE_TYPE
29 /// and combine it with an existing hash in an asymmetric fashion.
30 /// There must be a static function @code
31 /// static size_t hash(const VALUE_TYPE &value);
32 /// @endcode
33 template <typename VALUE_TYPE>
34 static inline void
35 SYShashCombine(SYS_HashType &hash, const VALUE_TYPE &value)
36 {
37  hboost::hash_combine(hash, value);
38 }
39 
40 /// Compute the hash for a range of values. The @c IT type must be hashable
41 /// @see SYShashCombine()
42 template <typename IT>
43 static inline SYS_HashType
44 SYShashRange(IT it, const IT &end)
45 {
46  SYS_HashType hash = 0;
47  for (; it != end; ++it)
48  SYShashCombine(hash, *it);
49  return hash;
50 }
51 
52 /// Compute the hash for a range of values. The @c IT type must be hashable
53 /// @see SYShashCombine()
54 template <typename IT>
55 static inline void
56 SYShashRange(SYS_HashType &hash, IT it, const IT &end)
57 {
58  for (; it != end; ++it)
59  SYShashCombine(hash, *it);
60 }
61 
62 #endif
std::size_t SYS_HashType
Define the type for hash values.
Definition: SYS_Hash.h:19
GLuint GLuint end
Definition: glcorearb.h:475
Definition: core.h:1131