X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f5db5af932c3255815542f4151b02367ea73c208..e4ccedf7b28e60d8109ea412c34fb0f22a68afd4:/include/wx/hashmap.h diff --git a/include/wx/hashmap.h b/include/wx/hashmap.h index b8689b86f6..8e8cffcc56 100644 --- a/include/wx/hashmap.h +++ b/include/wx/hashmap.h @@ -12,10 +12,6 @@ #ifndef _WX_HASHMAP_H_ #define _WX_HASHMAP_H_ -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma interface "hashmap.h" -#endif - #include "wx/string.h" #if (defined(HAVE_EXT_HASH_MAP) || defined(HAVE_HASH_MAP)) \ @@ -38,7 +34,7 @@ #endif #define _WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP ) \ - typedef WX_HASH_MAP_NAMESPACE::hash_map< KEY_T, VALUE_T, HASH_T, KEY_EQ_T > CLASSNAME; + typedef WX_HASH_MAP_NAMESPACE::hash_map< KEY_T, VALUE_T, HASH_T, KEY_EQ_T > CLASSNAME #else // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP) @@ -341,8 +337,8 @@ protected: \ /* returns NULL if not found */ \ Node** GetNodePtr( const const_key_type& key ) const \ { \ - unsigned long hash = m_hasher( key ); \ - Node** node = &m_table[hash % m_tableBuckets]; \ + size_t bucket = m_hasher( key ) % m_tableBuckets; \ + Node** node = &m_table[bucket]; \ \ while( *node ) \ { \ @@ -358,8 +354,8 @@ protected: \ /* expressing it in terms of GetNodePtr is 5-8% slower :-( */ \ Node* GetNode( const const_key_type& key ) const \ { \ - unsigned long hash = m_hasher( key ); \ - Node* node = m_table[hash % m_tableBuckets]; \ + size_t bucket = m_hasher( key ) % m_tableBuckets; \ + Node* node = m_table[bucket]; \ \ while( node ) \ { \ @@ -465,6 +461,15 @@ class WXDLLIMPEXP_BASE wxIntegerHash WX_HASH_MAP_NAMESPACE::hash uintHash; WX_HASH_MAP_NAMESPACE::hash shortHash; WX_HASH_MAP_NAMESPACE::hash ushortHash; + +#if defined wxLongLong_t && !defined wxLongLongIsLong + size_t longlongHash( wxLongLong_t x ) const + { + return longHash( wx_truncate_cast(long, x) ) ^ + longHash( wx_truncate_cast(long, x >> (sizeof(long) * 8)) ); + } +#endif + public: wxIntegerHash() { } size_t operator()( long x ) const { return longHash( x ); } @@ -473,6 +478,10 @@ public: size_t operator()( unsigned int x ) const { return uintHash( x ); } size_t operator()( short x ) const { return shortHash( x ); } size_t operator()( unsigned short x ) const { return ushortHash( x ); } +#if defined wxLongLong_t && !defined wxLongLongIsLong + size_t operator()( wxLongLong_t x ) const { return longlongHash(x); } + size_t operator()( wxULongLong_t x ) const { return longlongHash(x); } +#endif wxIntegerHash& operator=(const wxIntegerHash&) { return *this; } }; @@ -490,6 +499,10 @@ public: unsigned long operator()( unsigned int x ) const { return x; } unsigned long operator()( short x ) const { return (unsigned long)x; } unsigned long operator()( unsigned short x ) const { return x; } +#if defined wxLongLong_t && !defined wxLongLongIsLong + wxULongLong_t operator()( wxLongLong_t x ) const { return wx_static_cast(wxULongLong_t, x); } + wxULongLong_t operator()( wxULongLong_t x ) const { return x; } +#endif wxIntegerHash& operator=(const wxIntegerHash&) { return *this; } }; @@ -506,6 +519,10 @@ public: bool operator()( unsigned int a, unsigned int b ) const { return a == b; } bool operator()( short a, short b ) const { return a == b; } bool operator()( unsigned short a, unsigned short b ) const { return a == b; } +#if defined wxLongLong_t && !defined wxLongLongIsLong + bool operator()( wxLongLong_t a, wxLongLong_t b ) const { return a == b; } + bool operator()( wxULongLong_t a, wxULongLong_t b ) const { return a == b; } +#endif wxIntegerEqual& operator=(const wxIntegerEqual&) { return *this; } };