diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 04:50:36 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 04:50:36 +0000 |
commit | da89e6d30e57bd6dbb10b4d36b093ce9bbf5c666 (patch) | |
tree | 0c8d31d13521011dc52a3fbadbf9e7e27929308f /src/old/hash.cpp | |
parent | f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 (diff) | |
download | libbu++-da89e6d30e57bd6dbb10b4d36b093ce9bbf5c666.tar.gz libbu++-da89e6d30e57bd6dbb10b4d36b093ce9bbf5c666.tar.bz2 libbu++-da89e6d30e57bd6dbb10b4d36b093ce9bbf5c666.tar.xz libbu++-da89e6d30e57bd6dbb10b4d36b093ce9bbf5c666.zip |
The first batch seem to have made it alright. Unfortunately the Archive class
isn't done yet, I'm going to make it rely on streams, so those will be next,
then we can make it work all sortsa' well.
Diffstat (limited to 'src/old/hash.cpp')
-rw-r--r-- | src/old/hash.cpp | 113 |
1 files changed, 0 insertions, 113 deletions
diff --git a/src/old/hash.cpp b/src/old/hash.cpp deleted file mode 100644 index c52e6b1..0000000 --- a/src/old/hash.cpp +++ /dev/null | |||
@@ -1,113 +0,0 @@ | |||
1 | #include "hash.h" | ||
2 | |||
3 | subExceptionDef( HashException ) | ||
4 | |||
5 | template<> uint32_t __calcHashCode<int>( const int &k ) | ||
6 | { | ||
7 | return k; | ||
8 | } | ||
9 | |||
10 | template<> bool __cmpHashKeys<int>( const int &a, const int &b ) | ||
11 | { | ||
12 | return a == b; | ||
13 | } | ||
14 | |||
15 | template<> uint32_t __calcHashCode<unsigned int>( const unsigned int &k ) | ||
16 | { | ||
17 | return k; | ||
18 | } | ||
19 | |||
20 | template<> bool __cmpHashKeys<unsigned int>( const unsigned int &a, const unsigned int &b ) | ||
21 | { | ||
22 | return a == b; | ||
23 | } | ||
24 | |||
25 | template<> | ||
26 | uint32_t __calcHashCode<const char *>( const char * const &k ) | ||
27 | { | ||
28 | if (k == NULL) | ||
29 | { | ||
30 | return 0; | ||
31 | } | ||
32 | |||
33 | unsigned long int nPos = 0; | ||
34 | for( const char *s = k; *s; s++ ) | ||
35 | { | ||
36 | nPos = *s + (nPos << 6) + (nPos << 16) - nPos; | ||
37 | } | ||
38 | |||
39 | return nPos; | ||
40 | } | ||
41 | |||
42 | template<> bool __cmpHashKeys<const char *>( const char * const &a, const char * const &b ) | ||
43 | { | ||
44 | if( a == b ) | ||
45 | return true; | ||
46 | |||
47 | for(int j=0; a[j] == b[j]; j++ ) | ||
48 | if( a[j] == '\0' ) | ||
49 | return true; | ||
50 | |||
51 | return false; | ||
52 | } | ||
53 | |||
54 | template<> | ||
55 | uint32_t __calcHashCode<char *>( char * const &k ) | ||
56 | { | ||
57 | if (k == NULL) | ||
58 | { | ||
59 | return 0; | ||
60 | } | ||
61 | |||
62 | unsigned long int nPos = 0; | ||
63 | for( const char *s = k; *s; s++ ) | ||
64 | { | ||
65 | nPos = *s + (nPos << 6) + (nPos << 16) - nPos; | ||
66 | } | ||
67 | |||
68 | return nPos; | ||
69 | } | ||
70 | |||
71 | template<> bool __cmpHashKeys<char *>( char * const &a, char * const &b ) | ||
72 | { | ||
73 | if( a == b ) | ||
74 | return true; | ||
75 | |||
76 | for(int j=0; a[j] == b[j]; j++ ) | ||
77 | if( a[j] == '\0' ) | ||
78 | return true; | ||
79 | |||
80 | return false; | ||
81 | } | ||
82 | |||
83 | template<> uint32_t __calcHashCode<std::string>( const std::string &k ) | ||
84 | { | ||
85 | std::string::size_type j, sz = k.size(); | ||
86 | const char *s = k.c_str(); | ||
87 | |||
88 | unsigned long int nPos = 0; | ||
89 | for( j = 0; j < sz; j++, s++ ) | ||
90 | { | ||
91 | nPos = *s + (nPos << 6) + (nPos << 16) - nPos; | ||
92 | } | ||
93 | |||
94 | return nPos; | ||
95 | } | ||
96 | |||
97 | template<> bool __cmpHashKeys<std::string>( const std::string &a, const std::string &b ) | ||
98 | { | ||
99 | return a == b; | ||
100 | } | ||
101 | |||
102 | template<> uint32_t __calcHashCode<Hashable>( const Hashable &k ) | ||
103 | { | ||
104 | return 0; | ||
105 | //return k.getHashCode(); | ||
106 | } | ||
107 | |||
108 | template<> bool __cmpHashKeys<Hashable>( const Hashable &a, const Hashable &b ) | ||
109 | { | ||
110 | return false; | ||
111 | //return a.compareForHash( b ); | ||
112 | } | ||
113 | |||