diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 03:49:53 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 03:49:53 +0000 |
| commit | f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 (patch) | |
| tree | 13cdf64f7cf134f397a7165b7a3fe0807e37026b /src/old/hashfunctioncasestring.cpp | |
| parent | 74d4c8cd27334fc7204d5a8773deb3d424565778 (diff) | |
| download | libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.gz libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.bz2 libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.xz libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.zip | |
Ok, no code is left in src, it's all in src/old. We'll gradually move code back
into src as it's fixed and re-org'd. This includes tests, which, I may write a
unit test system into libbu++ just to make my life easier.
Diffstat (limited to 'src/old/hashfunctioncasestring.cpp')
| -rw-r--r-- | src/old/hashfunctioncasestring.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/old/hashfunctioncasestring.cpp b/src/old/hashfunctioncasestring.cpp new file mode 100644 index 0000000..6361f45 --- /dev/null +++ b/src/old/hashfunctioncasestring.cpp | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | #include <stdlib.h> | ||
| 2 | #include <string.h> | ||
| 3 | #include <ctype.h> | ||
| 4 | #include "hashfunctioncasestring.h" | ||
| 5 | |||
| 6 | HashFunctionCaseString::HashFunctionCaseString() | ||
| 7 | { | ||
| 8 | } | ||
| 9 | |||
| 10 | HashFunctionCaseString::~HashFunctionCaseString() | ||
| 11 | { | ||
| 12 | } | ||
| 13 | |||
| 14 | unsigned long int HashFunctionCaseString::hash( const void *id ) | ||
| 15 | { | ||
| 16 | const char *str = (const char *)id; | ||
| 17 | unsigned long int nPos = 0; | ||
| 18 | for( int j = 0; str[j] != '\0'; j++ ) | ||
| 19 | { | ||
| 20 | nPos = tolower(str[j]) + (nPos << 6) + (nPos << 16) - nPos; | ||
| 21 | // nPos += nPos<<16|(((unsigned long int)tolower(str[j]))<<((j*7)%24)); | ||
| 22 | } | ||
| 23 | return nPos; | ||
| 24 | } | ||
| 25 | |||
| 26 | bool HashFunctionCaseString::cmpIDs( const void *id1, const void *id2 ) | ||
| 27 | { | ||
| 28 | const char *str1 = (const char *)id1; | ||
| 29 | const char *str2 = (const char *)id2; | ||
| 30 | |||
| 31 | int j; | ||
| 32 | for( j = 0; str1[j] != '\0' && str2[j] != '\0'; j++ ) | ||
| 33 | { | ||
| 34 | if( tolower(str1[j]) != tolower(str2[j]) ) | ||
| 35 | return false; | ||
| 36 | } | ||
| 37 | return (str1[j]==str2[j]); | ||
| 38 | } | ||
| 39 | |||
