From 4b8bad3d711f39db84f094edf83c5496a3f02cd6 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 21 Nov 2006 12:23:13 +0000 Subject: 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! --- src/staticstring.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/staticstring.cpp') 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 ) unsigned long int StaticString::getHashCode() { unsigned long int nPos = nLen; - for( const char *s = (const char *)lpStr; *s; s++ ) + unsigned long int j = 0; + for( const char *s = (const char *)lpStr; j< nLen; s++, j++ ) { nPos = *s + (nPos << 6) + (nPos << 16) - nPos; } return nPos; } +bool StaticString::compareForHash( Hashable &other ) +{ + if( ((StaticString &)other).nLen != nLen ) + return false; + + const char *a = ((StaticString &)other).lpStr; + const char *b = lpStr; + if( a == b ) + return true; + + for( unsigned long j = 0; j < nLen; j++, a++, b++ ) + if( *a != *b ) + return false; + + return true; +} + -- cgit v1.2.3