aboutsummaryrefslogtreecommitdiff
path: root/src/hash.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hash.cpp')
-rw-r--r--src/hash.cpp69
1 files changed, 0 insertions, 69 deletions
diff --git a/src/hash.cpp b/src/hash.cpp
deleted file mode 100644
index 59572ec..0000000
--- a/src/hash.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/hash.h"
9
10namespace Bu { subExceptionDef( HashException ) }
11
12template<>
13uint32_t Bu::__calcHashCode<const char *>( const char * const &k )
14{
15 if (k == NULL)
16 {
17 return 0;
18 }
19
20 unsigned long int nPos = 0;
21 for( const char *s = k; *s; s++ )
22 {
23 nPos = *s + (nPos << 6) + (nPos << 16) - nPos;
24 }
25
26 return nPos;
27}
28
29template<> bool Bu::__cmpHashKeys<const char *>( const char * const &a, const char * const &b )
30{
31 if( a == b )
32 return true;
33
34 for(int j=0; a[j] == b[j]; j++ )
35 if( a[j] == '\0' )
36 return true;
37
38 return false;
39}
40
41template<>
42uint32_t Bu::__calcHashCode<char *>( char * const &k )
43{
44 if (k == NULL)
45 {
46 return 0;
47 }
48
49 unsigned long int nPos = 0;
50 for( const char *s = k; *s; s++ )
51 {
52 nPos = *s + (nPos << 6) + (nPos << 16) - nPos;
53 }
54
55 return nPos;
56}
57
58template<> bool Bu::__cmpHashKeys<char *>( char * const &a, char * const &b )
59{
60 if( a == b )
61 return true;
62
63 for(int j=0; a[j] == b[j]; j++ )
64 if( a[j] == '\0' )
65 return true;
66
67 return false;
68}
69