X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/77ffb5937e89927b621128789401db8921fe580f..0d53638f7147c18153f63fdfc096b17be6e22a27:/src/common/hashmap.cpp diff --git a/src/common/hashmap.cpp b/src/common/hashmap.cpp index 8f941c7275..a9c10e34f2 100644 --- a/src/common/hashmap.cpp +++ b/src/common/hashmap.cpp @@ -1,23 +1,18 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: hashmap.cpp +// Name: src/common/hashmap.cpp // Purpose: wxHashMap implementation // Author: Mattia Barbon // Modified by: // Created: 29/01/2002 -// RCS-ID: $Id$ // Copyright: (c) Mattia Barbon -// Licence: wxWidgets licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "hashmap.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop #endif #include "wx/hashmap.h" @@ -26,7 +21,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; @@ -42,25 +38,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] = @@ -84,7 +69,7 @@ unsigned long _wxHashTableBase2::GetNextPrime( unsigned long n ) } /* someone might try to alloc a 2^32-element hash table */ - wxFAIL_MSG( _T("hash table too big?") ); + wxFAIL_MSG( wxT("hash table too big?") ); /* quiet warning */ return 0; @@ -117,7 +102,7 @@ void _wxHashTableBase2::DeleteNodes( size_t buckets, while( node ) { - tmp = node->m_nxt; + tmp = node->m_next; dtor( node ); node = tmp; } @@ -140,9 +125,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; } } @@ -153,4 +138,4 @@ _wxHashTable_NodeBase* _wxHashTableBase2::DummyProcessNode(_wxHashTable_NodeBase return node; } -#endif // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP) +#endif // wxNEEDS_WX_HASH_MAP