aboutsummaryrefslogtreecommitdiff
path: root/src/hash.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-03-25 20:00:08 +0000
committerMike Buland <eichlan@xagasoft.com>2012-03-25 20:00:08 +0000
commit469bbcf0701e1eb8a6670c23145b0da87357e178 (patch)
treeb5b062a16e46a6c5d3410b4e574cd0cc09057211 /src/hash.cpp
parentee1b79396076edc4e30aefb285fada03bb45e80d (diff)
downloadlibbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.gz
libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.bz2
libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.xz
libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.zip
Code is all reorganized. We're about ready to release. I should write up a
little explenation of the arrangement.
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