aboutsummaryrefslogtreecommitdiff
path: root/src/hash.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hash.cpp')
-rw-r--r--src/hash.cpp34
1 files changed, 11 insertions, 23 deletions
diff --git a/src/hash.cpp b/src/hash.cpp
index c52e6b1..a207c29 100644
--- a/src/hash.cpp
+++ b/src/hash.cpp
@@ -1,29 +1,29 @@
1#include "hash.h" 1#include "hash.h"
2 2
3subExceptionDef( HashException ) 3namespace Bu { subExceptionDef( HashException ) }
4 4
5template<> uint32_t __calcHashCode<int>( const int &k ) 5template<> uint32_t Bu::__calcHashCode<int>( const int &k )
6{ 6{
7 return k; 7 return k;
8} 8}
9 9
10template<> bool __cmpHashKeys<int>( const int &a, const int &b ) 10template<> bool Bu::__cmpHashKeys<int>( const int &a, const int &b )
11{ 11{
12 return a == b; 12 return a == b;
13} 13}
14 14
15template<> uint32_t __calcHashCode<unsigned int>( const unsigned int &k ) 15template<> uint32_t Bu::__calcHashCode<unsigned int>( const unsigned int &k )
16{ 16{
17 return k; 17 return k;
18} 18}
19 19
20template<> bool __cmpHashKeys<unsigned int>( const unsigned int &a, const unsigned int &b ) 20template<> bool Bu::__cmpHashKeys<unsigned int>( const unsigned int &a, const unsigned int &b )
21{ 21{
22 return a == b; 22 return a == b;
23} 23}
24 24
25template<> 25template<>
26uint32_t __calcHashCode<const char *>( const char * const &k ) 26uint32_t Bu::__calcHashCode<const char *>( const char * const &k )
27{ 27{
28 if (k == NULL) 28 if (k == NULL)
29 { 29 {
@@ -39,7 +39,7 @@ uint32_t __calcHashCode<const char *>( const char * const &k )
39 return nPos; 39 return nPos;
40} 40}
41 41
42template<> bool __cmpHashKeys<const char *>( const char * const &a, const char * const &b ) 42template<> bool Bu::__cmpHashKeys<const char *>( const char * const &a, const char * const &b )
43{ 43{
44 if( a == b ) 44 if( a == b )
45 return true; 45 return true;
@@ -52,7 +52,7 @@ template<> bool __cmpHashKeys<const char *>( const char * const &a, const char *
52} 52}
53 53
54template<> 54template<>
55uint32_t __calcHashCode<char *>( char * const &k ) 55uint32_t Bu::__calcHashCode<char *>( char * const &k )
56{ 56{
57 if (k == NULL) 57 if (k == NULL)
58 { 58 {
@@ -68,7 +68,7 @@ uint32_t __calcHashCode<char *>( char * const &k )
68 return nPos; 68 return nPos;
69} 69}
70 70
71template<> bool __cmpHashKeys<char *>( char * const &a, char * const &b ) 71template<> bool Bu::__cmpHashKeys<char *>( char * const &a, char * const &b )
72{ 72{
73 if( a == b ) 73 if( a == b )
74 return true; 74 return true;
@@ -80,7 +80,7 @@ template<> bool __cmpHashKeys<char *>( char * const &a, char * const &b )
80 return false; 80 return false;
81} 81}
82 82
83template<> uint32_t __calcHashCode<std::string>( const std::string &k ) 83template<> uint32_t Bu::__calcHashCode<std::string>( const std::string &k )
84{ 84{
85 std::string::size_type j, sz = k.size(); 85 std::string::size_type j, sz = k.size();
86 const char *s = k.c_str(); 86 const char *s = k.c_str();
@@ -94,20 +94,8 @@ template<> uint32_t __calcHashCode<std::string>( const std::string &k )
94 return nPos; 94 return nPos;
95} 95}
96 96
97template<> bool __cmpHashKeys<std::string>( const std::string &a, const std::string &b ) 97template<> bool Bu::__cmpHashKeys<std::string>( const std::string &a, const std::string &b )
98{ 98{
99 return a == b; 99 return a == b;
100} 100}
101 101
102template<> uint32_t __calcHashCode<Hashable>( const Hashable &k )
103{
104 return 0;
105 //return k.getHashCode();
106}
107
108template<> bool __cmpHashKeys<Hashable>( const Hashable &a, const Hashable &b )
109{
110 return false;
111 //return a.compareForHash( b );
112}
113