00001 #ifndef _GEMFIRE_CACHEABLEKEYS_HPP_
00002 #define _GEMFIRE_CACHEABLEKEYS_HPP_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "gfcpp_globals.hpp"
00013
00014
00015 namespace gemfire
00016 {
00017 namespace serializer
00018 {
00019
00020 template <typename TObj>
00021 inline bool equals( const TObj& x, const TObj& y )
00022 {
00023 return ( x == y );
00024 }
00025
00026
00027
00028 inline uint32_t hashcode( const bool value )
00029 {
00030 if (value) return 1231;
00031 else return 1237;
00032 }
00033
00034 inline uint32_t hashcode( const uint8_t value )
00035 {
00036 return (uint32_t)value;
00037 }
00038
00039 inline uint32_t hashcode( const int8_t value )
00040 {
00041 return (uint32_t)value;
00042 }
00043
00044 inline uint32_t hashcode( const uint16_t value )
00045 {
00046 return (uint32_t)value;
00047 }
00048
00049 inline uint32_t hashcode( const int16_t value )
00050 {
00051 return (uint32_t)value;
00052 }
00053
00054 inline uint32_t hashcode( const uint32_t value )
00055 {
00056 return value;
00057 }
00058
00059 inline uint32_t hashcode( const int32_t value )
00060 {
00061 return (uint32_t)value;
00062 }
00063
00064 inline uint32_t hashcode( const uint64_t value )
00065 {
00066 uint32_t hash = (uint32_t)value;
00067 hash = hash ^ (uint32_t)(value >> 32);
00068 return hash;
00069 }
00070
00071 inline uint32_t hashcode( const int64_t value )
00072 {
00073 uint32_t hash = (uint32_t)value;
00074 hash = hash ^ (uint32_t)(value >> 32);
00075 return hash;
00076 }
00077
00078 inline uint32_t hashcode( const float value )
00079 {
00080 union float_uint32_t
00081 {
00082 float f;
00083 uint32_t u;
00084 } v;
00085 v.f = value;
00086 return v.u;
00087 }
00088
00089 inline uint32_t hashcode( const double value )
00090 {
00091 union double_uint64_t
00092 {
00093 double d;
00094 uint64_t u;
00095 } v;
00096 v.d = value;
00097 return hashcode(v.u);
00098 }
00099
00100 }
00101 }
00102
00103
00104 #endif // _GEMFIRE_CACHEABLEKEYS_HPP_