X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/19230604c4a41c9a058e22a1719f4919c7f2dd37..9e5b30eb3e7545940135671fd21311d7c5596c66:/src/common/hash.cpp diff --git a/src/common/hash.cpp b/src/common/hash.cpp index 2909e48183..f8e5ec096b 100644 --- a/src/common/hash.cpp +++ b/src/common/hash.cpp @@ -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; @@ -395,7 +420,7 @@ void wxHashTable::Put (long key, long value, wxObject * object) if (!hash_table[position]) { - hash_table[position] = new wxList (wxKEY_STRING); + hash_table[position] = new wxList (wxKEY_INTEGER); if (m_deleteContents) hash_table[position]->DeleteContents(TRUE); } @@ -413,7 +438,7 @@ void wxHashTable::Put (long key, const wxChar *value, wxObject * object) if (!hash_table[position]) { - hash_table[position] = new wxList (wxKEY_INTEGER); + hash_table[position] = new wxList (wxKEY_STRING); if (m_deleteContents) hash_table[position]->DeleteContents(TRUE); }