]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/hash.h
Cleaned up remains of outdated 3D effect handling.
[wxWidgets.git] / include / wx / hash.h
index 199a6193558fc82169bc327e520d6618de188033..3720dd0c1fd0c99246c3e1d932baa2bf42cb1d13 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef _WX_HASH_H__
 #define _WX_HASH_H__
 
 #ifndef _WX_HASH_H__
 #define _WX_HASH_H__
 
-#if defined(__GNUG__) && !defined(__APPLE__)
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
 #pragma interface "hash.h"
 #endif
 
 #pragma interface "hash.h"
 #endif
 
@@ -140,7 +140,24 @@ WX_DECLARE_EXPORTED_HASH_MAP( wxHashKeyValue,
                               void*,
                               wxHashTableHash,
                               wxHashTableEqual,
                               void*,
                               wxHashTableHash,
                               wxHashTableEqual,
-                              wxHashTableBaseBase );
+                              wxHashTableBaseBaseBase );
+
+// hack: we should really have HASH_MULTI(MAP|SET), but this requires
+// less work
+
+class WXDLLIMPEXP_BASE wxHashTableBaseBase : public wxHashTableBaseBaseBase
+{
+public:
+    wxHashTableBaseBase(size_t size, const wxHashTableHash& hash,
+                        const wxHashTableEqual& equal)
+        : wxHashTableBaseBaseBase(size, hash, equal)
+    { }
+
+    void multi_insert(const wxHashKeyValue& key, void* value)
+    {
+        CreateNodeLast(value_type(key, value));
+    }
+};
 
 class WXDLLIMPEXP_BASE wxHashTableBase
 {
 
 class WXDLLIMPEXP_BASE wxHashTableBase
 {
@@ -151,7 +168,11 @@ public:
                  wxHashTableEqual( keyType ) ),
           m_keyType( keyType ) { }
 
                  wxHashTableEqual( keyType ) ),
           m_keyType( keyType ) { }
 
-    ~wxHashTableBase()
+    ~wxHashTableBase() { Clear(); }
+
+    size_t GetCount() const { return m_map.size(); }
+
+    void Clear()
     {
         if( m_keyType == wxKEY_STRING )
         {
     {
         if( m_keyType == wxKEY_STRING )
         {
@@ -164,26 +185,30 @@ public:
                 delete[] tmp; // used in operator++
             }
         }
                 delete[] tmp; // used in operator++
             }
         }
+        m_map.clear();
     }
     }
-
-    size_t GetCount() const { return m_map.size(); }
 protected:
     void DoPut( long key, void* data )
     {
 protected:
     void DoPut( long key, void* data )
     {
+        wxASSERT( m_keyType == wxKEY_INTEGER );
+
         wxHashKeyValue k; k.integer = key;
         wxHashKeyValue k; k.integer = key;
-        m_map[k] = data;
+        m_map.multi_insert(k, data);
     }
 
     void DoPut( const wxChar* key, void* data )
     {
     }
 
     void DoPut( const wxChar* key, void* data )
     {
+        wxASSERT( m_keyType == wxKEY_STRING );
+
         wxHashKeyValue k;
         wxHashKeyValue k;
-        k.string = new wxChar[wxStrlen(key) + 1];
-        wxStrcpy(k.string, key);
-        m_map[k] = data;
+        k.string = wxStrcpy(new wxChar[wxStrlen(key) + 1], key);
+        m_map.multi_insert(k, data);
     }
 
     void* DoGet( long key ) const
     {
     }
 
     void* DoGet( long key ) const
     {
+        wxASSERT( m_keyType == wxKEY_INTEGER );
+
         wxHashKeyValue k; k.integer = key;
         wxHashTableBaseBase::const_iterator it = m_map.find( k );
 
         wxHashKeyValue k; k.integer = key;
         wxHashTableBaseBase::const_iterator it = m_map.find( k );
 
@@ -192,6 +217,8 @@ protected:
 
     void* DoGet( const wxChar* key ) const
     {
 
     void* DoGet( const wxChar* key ) const
     {
+        wxASSERT( m_keyType == wxKEY_STRING );
+
         wxHashKeyValue k; k.string = (wxChar*)key;
         wxHashTableBaseBase::const_iterator it = m_map.find( k );
 
         wxHashKeyValue k; k.string = (wxChar*)key;
         wxHashTableBaseBase::const_iterator it = m_map.find( k );
 
@@ -200,6 +227,8 @@ protected:
 
     void* DoDelete( long key )
     {
 
     void* DoDelete( long key )
     {
+        wxASSERT( m_keyType == wxKEY_INTEGER );
+
         wxHashKeyValue k; k.integer = key;
         wxHashTableBaseBase::iterator it = m_map.find( k );
         
         wxHashKeyValue k; k.integer = key;
         wxHashTableBaseBase::iterator it = m_map.find( k );
         
@@ -216,6 +245,8 @@ protected:
 
     void* DoDelete( const wxChar* key )
     {
 
     void* DoDelete( const wxChar* key )
     {
+        wxASSERT( m_keyType == wxKEY_STRING );
+
         wxHashKeyValue k; k.string = (wxChar*)key;
         wxHashTableBaseBase::iterator it = m_map.find( k );
         
         wxHashKeyValue k; k.string = (wxChar*)key;
         wxHashTableBaseBase::iterator it = m_map.find( k );
         
@@ -342,7 +373,7 @@ public:
 
         dummy* operator->() { return (dummy*)this; }
     };
 
         dummy* operator->() { return (dummy*)this; }
     };
-    typedef class compatibility_iterator citer;
+    typedef compatibility_iterator citer;
 
     class dummy
     {
 
     class dummy
     {
@@ -360,12 +391,6 @@ public:
             it lit = i->m_iter;
             return citer( i->m_hash, ++lit );
         }
             it lit = i->m_iter;
             return citer( i->m_hash, ++lit );
         }
-        citer GetPrevious() const
-        {
-            citer* i = (citer*)this;
-            it lit = i->m_iter;
-            return citer( i->m_hash, ++lit );
-        }
         void SetData( wxObject* e )
         {
             citer* i = (citer*)this;
         void SetData( wxObject* e )
         {
             citer* i = (citer*)this;
@@ -390,8 +415,8 @@ public:
     wxObject *Get(const wxChar *value) const { return (wxObject*)DoGet( value ); }
 
     // Deletes entry and returns data if found
     wxObject *Get(const wxChar *value) const { return (wxObject*)DoGet( value ); }
 
     // Deletes entry and returns data if found
-    wxObject *Delete(long key) { return (wxObject*)DoGet( key ); }
-    wxObject *Delete(const wxChar *key) { return (wxObject*)DoGet( key ); }
+    wxObject *Delete(long key) { return (wxObject*)DoDelete( key ); }
+    wxObject *Delete(const wxChar *key) { return (wxObject*)DoDelete( key ); }
 
 #if 0
     // Construct your own integer key from a string, e.g. in case
 
 #if 0
     // Construct your own integer key from a string, e.g. in case
@@ -410,7 +435,9 @@ public:
         return it;
     }
 
         return it;
     }
 
-    void Clear() { m_map.clear(); }
+    void Clear() { wxHashTableBase::Clear(); }
+
+    size_t GetCount() const { return wxHashTableBase::GetCount(); }
 private:
     compatibility_iterator m_iter;
 };
 private:
     compatibility_iterator m_iter;
 };
@@ -584,6 +611,8 @@ private:
             ((listclass *)m_hashTable[slot])->Append(value, data);             \
             m_count++;                                                         \
         }                                                                      \
             ((listclass *)m_hashTable[slot])->Append(value, data);             \
             m_count++;                                                         \
         }                                                                      \
+                                                                               \
+        DECLARE_NO_COPY_CLASS(hashclass)                                       \
     }
 
 #endif
     }
 
 #endif