]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/hash.cpp
fixed wxBase compilation (what was msgdlg.h doing in wxchar.cpp?)
[wxWidgets.git] / src / common / hash.cpp
index e8c47429f275791f8498c9eea66b0b48bb02847e..f8e5ec096b05c4bc64d14245ad50af7671c30678 100644 (file)
@@ -310,6 +310,30 @@ wxString wxStringHashTable::Get(long key, bool *wasFound) const
     return _T("");
 }
 
+bool wxStringHashTable::Delete(long key) const
+{
+    wxCHECK_MSG( m_hashSize, FALSE, _T("must call Create() first") );
+
+    size_t slot = (size_t)abs((int)(key % (long)m_hashSize));
+
+    wxArrayLong *keys = m_keys[slot];
+    if ( keys )
+    {
+        size_t count = keys->GetCount();
+        for ( size_t n = 0; n < count; n++ )
+        {
+            if ( keys->Item(n) == key )
+            {
+                keys->RemoveAt(n);
+                m_values[slot]->RemoveAt(n);
+                return TRUE;
+            }
+        }
+    }
+
+    return FALSE;
+}
+
 // ----------------------------------------------------------------------------
 // old not type safe wxHashTable
 // ----------------------------------------------------------------------------
@@ -370,6 +394,7 @@ bool wxHashTable::Create(int the_key_type, int size)
 void wxHashTable::DoCopy(const wxHashTable& table)
 {
   n = table.n;
+  m_count = table.m_count;
   current_position = table.current_position;
   current_node = NULL; // doesn't matter - Next() will reconstruct it
   key_type = table.key_type;