DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
utlSTDHeaders.h
Go to the documentation of this file.
1 
18 #ifndef __utlSTDHeaders_h
19 #define __utlSTDHeaders_h
20 
25 #if __cplusplus < 201103L
26 
27 #include <tr1/memory>
28 #define utl_shared_ptr std::tr1::shared_ptr
29 #include <tr1/unordered_map>
30 #define utl_unordered_map std::tr1::unordered_map
31 #define utl_hash std::tr1::hash
32 
33 #define __UTL_constexpr const
34 
36 extern "C" {
37 #include <complex.h>
38 #undef complex
39 }
40 #include <complex>
41 
42 
43 #else
44 
45 #define __UTL_constexpr constexpr
46 
47 #include <memory>
48 #define utl_shared_ptr std::shared_ptr
49 #include <unordered_map>
50 #define utl_unordered_map std::unordered_map
51 #define utl_hash std::hash
52 
53 #include <complex>
54 #include <type_traits>
55 
56 #endif
57 
58 // #include <functional>
59 
60 #include <vector>
61 
62 namespace utl
63 {
64 
68 template <class T>
69 inline void
70 hash_combine(std::size_t& seed, T const& v)
71 {
72  seed ^= utl_hash<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
73 }
74 
75 }
76 
77 namespace std
78 {
79 
80 #if __cplusplus < 201103L
81 namespace tr1
82 {
83 #endif
84 
85 template<typename T>
86 class hash<std::vector<T> >
87 {
88 public:
89 typedef std::vector<T> argument_type;
90 typedef std::size_t result_type;
91 result_type operator()(argument_type const& in) const
92  {
93  size_t size = in.size();
94  size_t seed = 0;
95  for (size_t i = 0; i < size; i++) //Combine the hash of the current vector with the hashes of the previous ones
96  utl::hash_combine(seed, in[i]);
97  return seed;
98  }
99 };
100 
101 #if __cplusplus < 201103L
102 }
103 #endif
104 
105 }
106 
109 #endif
STL namespace.
std::vector< T > argument_type
Definition: utlSTDHeaders.h:89
Definition: utl.h:90
static int seed
seed for random number generation
Definition: misc.h:34
result_type operator()(argument_type const &in) const
Definition: utlSTDHeaders.h:91
void hash_combine(std::vcl_size_t &seed, T const &v)
Definition: utlSTDHeaders.h:70