summaryrefslogtreecommitdiff
path: root/src/hashfunctionstring.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hashfunctionstring.cpp')
-rw-r--r--src/hashfunctionstring.cpp36
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
3HashFunctionString::HashFunctionString()
4{
5}
6
7HashFunctionString::~HashFunctionString()
8{
9}
10
11unsigned 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
23bool 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