VMware GemFire Native Client Cache Reference  9.0.6
CacheableKeys.hpp
1 #ifndef _GEMFIRE_CACHEABLEKEYS_HPP_
2 #define _GEMFIRE_CACHEABLEKEYS_HPP_
3 
4 /*=========================================================================
5  * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
6  * This product is protected by U.S. and international copyright
7  * and intellectual property laws. Pivotal products are covered by
8  * more patents listed at http://www.pivotal.io/patents.
9  *=========================================================================
10  */
11 
12 #include "gfcpp_globals.hpp"
13 
14 
15 namespace gemfire
16 {
17  namespace serializer
18  {
19 
20  template <typename TObj>
21  inline bool equals( const TObj& x, const TObj& y )
22  {
23  return ( x == y );
24  }
25 
26 
27 
28  inline uint32_t hashcode( const bool value )
29  {
30  if (value) return 1231;
31  else return 1237;
32  }
33 
34  inline uint32_t hashcode( const uint8_t value )
35  {
36  return (uint32_t)value;
37  }
38 
39  inline uint32_t hashcode( const int8_t value )
40  {
41  return (uint32_t)value;
42  }
43 
44  inline uint32_t hashcode( const uint16_t value )
45  {
46  return (uint32_t)value;
47  }
48 
49  inline uint32_t hashcode( const int16_t value )
50  {
51  return (uint32_t)value;
52  }
53 
54  inline uint32_t hashcode( const uint32_t value )
55  {
56  return value;
57  }
58 
59  inline uint32_t hashcode( const int32_t value )
60  {
61  return (uint32_t)value;
62  }
63 
64  inline uint32_t hashcode( const uint64_t value )
65  {
66  uint32_t hash = (uint32_t)value;
67  hash = hash ^ (uint32_t)(value >> 32);
68  return hash;
69  }
70 
71  inline uint32_t hashcode( const int64_t value )
72  {
73  uint32_t hash = (uint32_t)value;
74  hash = hash ^ (uint32_t)(value >> 32);
75  return hash;
76  }
77 
78  inline uint32_t hashcode( const float value )
79  {
80  union float_uint32_t
81  {
82  float f;
83  uint32_t u;
84  } v;
85  v.f = value;
86  return v.u;
87  }
88 
89  inline uint32_t hashcode( const double value )
90  {
91  union double_uint64_t
92  {
93  double d;
94  uint64_t u;
95  } v;
96  v.d = value;
97  return hashcode(v.u);
98  }
99 
100  }
101 }
102 
103 
104 #endif // _GEMFIRE_CACHEABLEKEYS_HPP_
This namespace contains all the GemFire C++ API classes, enumerations and globals.
Definition: Assert.hpp:19

GemFire C++ Cache API Documentation