aboutsummaryrefslogtreecommitdiff
path: root/src/staticstring.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-11-21 12:23:13 +0000
committerMike Buland <eichlan@xagasoft.com>2006-11-21 12:23:13 +0000
commit4b8bad3d711f39db84f094edf83c5496a3f02cd6 (patch)
treebbaf654af3e82e67544ae17f07b7fbe7d02ce0ec /src/staticstring.cpp
parent737b1aee54da9ff45a4fb6eb7e636eff9019128e (diff)
downloadlibbu++-4b8bad3d711f39db84f094edf83c5496a3f02cd6.tar.gz
libbu++-4b8bad3d711f39db84f094edf83c5496a3f02cd6.tar.bz2
libbu++-4b8bad3d711f39db84f094edf83c5496a3f02cd6.tar.xz
libbu++-4b8bad3d711f39db84f094edf83c5496a3f02cd6.zip
Wow, craziness. Part way through working on the confpair system I got some
sudden insperation and completely redid Hash. Now everything but delete is implemented, including typesafe iterators and more. It's really cool, and everyone should check it out and start using it right away!
Diffstat (limited to 'src/staticstring.cpp')
-rw-r--r--src/staticstring.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/staticstring.cpp b/src/staticstring.cpp
index 9eac92e..0012b0f 100644
--- a/src/staticstring.cpp
+++ b/src/staticstring.cpp
@@ -243,10 +243,28 @@ bool StaticString::operator!=( StaticString &str )
243unsigned long int StaticString::getHashCode() 243unsigned long int StaticString::getHashCode()
244{ 244{
245 unsigned long int nPos = nLen; 245 unsigned long int nPos = nLen;
246 for( const char *s = (const char *)lpStr; *s; s++ ) 246 unsigned long int j = 0;
247 for( const char *s = (const char *)lpStr; j< nLen; s++, j++ )
247 { 248 {
248 nPos = *s + (nPos << 6) + (nPos << 16) - nPos; 249 nPos = *s + (nPos << 6) + (nPos << 16) - nPos;
249 } 250 }
250 return nPos; 251 return nPos;
251} 252}
252 253
254bool StaticString::compareForHash( Hashable &other )
255{
256 if( ((StaticString &)other).nLen != nLen )
257 return false;
258
259 const char *a = ((StaticString &)other).lpStr;
260 const char *b = lpStr;
261 if( a == b )
262 return true;
263
264 for( unsigned long j = 0; j < nLen; j++, a++, b++ )
265 if( *a != *b )
266 return false;
267
268 return true;
269}
270