]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/hashmap.h
use LLONG_MIN instead of -1 (which is a valid time value corresponding to 1ms before...
[wxWidgets.git] / include / wx / hashmap.h
index 97e0456013db30ba3bb5cabf4e22f8780a68dbfc..41aaccb230facd6b1fa590b9ddf15adf7ba72dab 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        hashmap.h
+// Name:        wx/hashmap.h
 // Purpose:     wxHashMap class
 // Author:      Mattia Barbon
 // Modified by:
 // Purpose:     wxHashMap class
 // Author:      Mattia Barbon
 // Modified by:
@@ -202,6 +202,7 @@ public: \
     { \
     public: \
         const_iterator() : Iterator() {} \
     { \
     public: \
         const_iterator() : Iterator() {} \
+        const_iterator(iterator i) : Iterator(i) {} \
         const_iterator( Node* node, const Self* ht ) \
             : Iterator( node, (Self*)ht ) {} \
         const_iterator& operator++() { PlusPlus();return *this; } \
         const_iterator( Node* node, const Self* ht ) \
             : Iterator( node, (Self*)ht ) {} \
         const_iterator& operator++() { PlusPlus();return *this; } \
@@ -344,8 +345,8 @@ protected: \
         { \
             if( m_equals( m_getKey( (*node)->m_value ), key ) ) \
                 return node; \
         { \
             if( m_equals( m_getKey( (*node)->m_value ), key ) ) \
                 return node; \
-            /* Tell the compiler to not do any strict-aliasing assumptions with the void cast */ \
-            node = (Node**)(void*)&(*node)->m_nxt; \
+            /* Tell the compiler to not do any strict-aliasing assumptions with a void cast? Can we make such a runtime guarantee? */ \
+            node = (Node**)&(*node)->m_nxt; \
         } \
  \
         return NULL; \
         } \
  \
         return NULL; \
@@ -464,11 +465,19 @@ class WXDLLIMPEXP_BASE wxIntegerHash
     WX_HASH_MAP_NAMESPACE::hash<unsigned short> ushortHash;
 
 #if defined wxLongLong_t && !defined wxLongLongIsLong
     WX_HASH_MAP_NAMESPACE::hash<unsigned short> ushortHash;
 
 #if defined wxLongLong_t && !defined wxLongLongIsLong
+    // hash<wxLongLong_t> ought to work but doesn't on some compilers
+    #if (!defined SIZEOF_LONG_LONG && SIZEOF_LONG == 4) \
+        || (defined SIZEOF_LONG_LONG && SIZEOF_LONG_LONG == SIZEOF_LONG * 2)
     size_t longlongHash( wxLongLong_t x ) const
     {
         return longHash( wx_truncate_cast(long, x) ) ^
                longHash( wx_truncate_cast(long, x >> (sizeof(long) * 8)) );
     }
     size_t longlongHash( wxLongLong_t x ) const
     {
         return longHash( wx_truncate_cast(long, x) ) ^
                longHash( wx_truncate_cast(long, x >> (sizeof(long) * 8)) );
     }
+    #elif defined SIZEOF_LONG_LONG && SIZEOF_LONG_LONG == SIZEOF_LONG
+    WX_HASH_MAP_NAMESPACE::hash<long> longlongHash;
+    #else
+    WX_HASH_MAP_NAMESPACE::hash<wxLongLong_t> longlongHash;
+    #endif
 #endif
 
 public:
 #endif
 
 public:
@@ -640,7 +649,10 @@ public: \
  \
     /* count() == 0 | 1 */ \
     size_type count( const const_key_type& key ) \
  \
     /* count() == 0 | 1 */ \
     size_type count( const const_key_type& key ) \
-        { return GetNode( key ) ? 1 : 0; } \
+    { \
+        /* explicit cast needed to suppress CodeWarrior warnings */ \
+        return (size_type)(GetNode( key ) ? 1 : 0); \
+    } \
 }
 
 #endif // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP)
 }
 
 #endif // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP)
@@ -704,4 +716,3 @@ WX_DECLARE_HASH_MAP_WITH_DECL( long, long, wxIntegerHash, wxIntegerEqual,
 
 
 #endif // _WX_HASHMAP_H_
 
 
 #endif // _WX_HASHMAP_H_
-