diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2006-07-26 21:58:35 +0000 | 
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2006-07-26 21:58:35 +0000 | 
| commit | 76ed3c164662f4ee4c109bb2054c61c99ea86251 (patch) | |
| tree | 301d4687f95a457304b0e796984b62fa89992718 /src/staticstring.cpp | |
| parent | 579c3ac445043122b0a702bdb2542d9ea404b62e (diff) | |
| download | libbu++-76ed3c164662f4ee4c109bb2054c61c99ea86251.tar.gz libbu++-76ed3c164662f4ee4c109bb2054c61c99ea86251.tar.bz2 libbu++-76ed3c164662f4ee4c109bb2054c61c99ea86251.tar.xz libbu++-76ed3c164662f4ee4c109bb2054c61c99ea86251.zip | |
Added the not-yet-working hash class.  More thought must be done.  This doesn't
actually change any existing code really just adds a new class that you can't
use because it's commented out.  I'll probably move it to a branch.
Diffstat (limited to 'src/staticstring.cpp')
| -rw-r--r-- | src/staticstring.cpp | 25 | 
1 files changed, 25 insertions, 0 deletions
| diff --git a/src/staticstring.cpp b/src/staticstring.cpp index fa61e62..9eac92e 100644 --- a/src/staticstring.cpp +++ b/src/staticstring.cpp | |||
| @@ -25,6 +25,13 @@ StaticString::StaticString( const char *lpNewStr, int nNewLen ) | |||
| 25 | setString( lpNewStr, nNewLen ); | 25 | setString( lpNewStr, nNewLen ); | 
| 26 | } | 26 | } | 
| 27 | 27 | ||
| 28 | StaticString::StaticString( const char *lpNewStr ) | ||
| 29 | { | ||
| 30 | lpStr = NULL; | ||
| 31 | nLen = 0; | ||
| 32 | setString( lpNewStr, -1 ); | ||
| 33 | } | ||
| 34 | |||
| 28 | StaticString::StaticString( StaticString &xSrcStr, int nNewLen ) | 35 | StaticString::StaticString( StaticString &xSrcStr, int nNewLen ) | 
| 29 | { | 36 | { | 
| 30 | lpStr = NULL; | 37 | lpStr = NULL; | 
| @@ -32,6 +39,13 @@ StaticString::StaticString( StaticString &xSrcStr, int nNewLen ) | |||
| 32 | setString( xSrcStr, nNewLen ); | 39 | setString( xSrcStr, nNewLen ); | 
| 33 | } | 40 | } | 
| 34 | 41 | ||
| 42 | StaticString::StaticString( StaticString &xSrcStr ) | ||
| 43 | { | ||
| 44 | lpStr = NULL; | ||
| 45 | nLen = 0; | ||
| 46 | setString( xSrcStr, -1 ); | ||
| 47 | } | ||
| 48 | |||
| 35 | StaticString::~StaticString() | 49 | StaticString::~StaticString() | 
| 36 | { | 50 | { | 
| 37 | if( lpStr != NULL ) delete[] lpStr; | 51 | if( lpStr != NULL ) delete[] lpStr; | 
| @@ -225,3 +239,14 @@ bool StaticString::operator!=( StaticString &str ) | |||
| 225 | for(; *a == *b; a++, b++ ) if( *a == '\0' && *b == '\0' ) return false; | 239 | for(; *a == *b; a++, b++ ) if( *a == '\0' && *b == '\0' ) return false; | 
| 226 | return true; | 240 | return true; | 
| 227 | } | 241 | } | 
| 242 | |||
| 243 | unsigned long int StaticString::getHashCode() | ||
| 244 | { | ||
| 245 | unsigned long int nPos = nLen; | ||
| 246 | for( const char *s = (const char *)lpStr; *s; s++ ) | ||
| 247 | { | ||
| 248 | nPos = *s + (nPos << 6) + (nPos << 16) - nPos; | ||
| 249 | } | ||
| 250 | return nPos; | ||
| 251 | } | ||
| 252 | |||
