X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8907154c1a8a6882c6797d1f16393ddfb23e7f3a..d7ad5a0289b22d16a67b9fc2efe1a721e4a5a1ae:/src/common/hashmap.cpp diff --git a/src/common/hashmap.cpp b/src/common/hashmap.cpp index d5b3229b74..cf0343ed38 100644 --- a/src/common/hashmap.cpp +++ b/src/common/hashmap.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: hashmap.cpp +// Name: src/common/hashmap.cpp // Purpose: wxHashMap implementation // Author: Mattia Barbon // Modified by: @@ -13,7 +13,7 @@ #include "wx/wxprec.h" #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop #endif #include "wx/hashmap.h" @@ -22,7 +22,8 @@ /* from requirements by Colin Plumb. */ /* (http://burtleburtle.net/bob/hash/doobs.html) */ /* adapted from Perl sources ( hv.h ) */ -unsigned long wxStringHash::wxCharStringHash( const wxChar* k ) +template +static unsigned long DoStringHash(T *k) { unsigned long hash = 0; @@ -38,25 +39,14 @@ unsigned long wxStringHash::wxCharStringHash( const wxChar* k ) return hash + (hash << 15); } -#if wxUSE_UNICODE -unsigned long wxStringHash::charStringHash( const char* k ) -{ - unsigned long hash = 0; +unsigned long wxStringHash::stringHash( const char* k ) + { return DoStringHash(k); } - while( *k ) - { - hash += *k++; - hash += (hash << 10); - hash ^= (hash >> 6); - } - hash += (hash << 3); - hash ^= (hash >> 11); +unsigned long wxStringHash::stringHash( const wchar_t* k ) + { return DoStringHash(k); } - return hash + (hash << 15); -} -#endif -#if !wxUSE_STL || !defined(HAVE_STL_HASH_MAP) +#ifdef wxNEEDS_WX_HASH_MAP /* from SGI STL */ const unsigned long _wxHashTableBase2::ms_primes[prime_count] = @@ -113,7 +103,7 @@ void _wxHashTableBase2::DeleteNodes( size_t buckets, while( node ) { - tmp = node->m_nxt; + tmp = node->m_next; dtor( node ); node = tmp; } @@ -136,9 +126,9 @@ void _wxHashTableBase2::CopyHashTable( _wxHashTable_NodeBase** srcTable, { size_t bucket = func( dst, node ); - nextnode = node->m_nxt; + nextnode = node->m_next; _wxHashTable_NodeBase* newnode = proc( node ); - newnode->m_nxt = dstTable[bucket]; + newnode->m_next = dstTable[bucket]; dstTable[bucket] = newnode; } } @@ -149,4 +139,4 @@ _wxHashTable_NodeBase* _wxHashTableBase2::DummyProcessNode(_wxHashTable_NodeBase return node; } -#endif // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP) +#endif // wxNEEDS_WX_HASH_MAP