diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-05-01 17:11:04 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-05-01 17:11:04 +0000 |
commit | f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54 (patch) | |
tree | 53cec4864776e07950e3c72f2a990a1017d08045 /src/hashfunctionstring.cpp | |
download | libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.tar.gz libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.tar.bz2 libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.tar.xz libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.zip |
libbu++ is finally laid out the way it should be, trunk, branches, and tags.
Diffstat (limited to '')
-rw-r--r-- | src/hashfunctionstring.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/hashfunctionstring.cpp b/src/hashfunctionstring.cpp new file mode 100644 index 0000000..8ea9f57 --- /dev/null +++ b/src/hashfunctionstring.cpp | |||
@@ -0,0 +1,36 @@ | |||
1 | #include "hashfunctionstring.h" | ||
2 | |||
3 | HashFunctionString::HashFunctionString() | ||
4 | { | ||
5 | } | ||
6 | |||
7 | HashFunctionString::~HashFunctionString() | ||
8 | { | ||
9 | } | ||
10 | |||
11 | unsigned long int HashFunctionString::hash( const void *id ) | ||
12 | { | ||
13 | const char *str = (const char *)id; | ||
14 | unsigned long int nPos = 0; | ||
15 | for( int j = 0; str[j] != '\0'; j++ ) | ||
16 | { | ||
17 | nPos = str[j] + (nPos << 6) + (nPos << 16) - nPos; | ||
18 | // nPos += nPos<<16|(((unsigned long int)str[j])<<((j*7)%24)); | ||
19 | } | ||
20 | return nPos; | ||
21 | } | ||
22 | |||
23 | bool HashFunctionString::cmpIDs( const void *id1, const void *id2 ) | ||
24 | { | ||
25 | const char *str1 = (const char *)id1; | ||
26 | const char *str2 = (const char *)id2; | ||
27 | |||
28 | int j; | ||
29 | for( j = 0; str1[j] != '\0' && str2[j] != '\0'; j++ ) | ||
30 | { | ||
31 | if( str1[j] != str2[j] ) | ||
32 | return false; | ||
33 | } | ||
34 | return (str1[j]==str2[j]); | ||
35 | } | ||
36 | |||