X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ea4508252199a29ebdcabc5b8137e360c3ec4938..8adb5d455797d5b656ef677c74359e5a578b539f:/src/common/hash.cpp?ds=sidebyside diff --git a/src/common/hash.cpp b/src/common/hash.cpp index 1c268e7c97..9882539bb4 100644 --- a/src/common/hash.cpp +++ b/src/common/hash.cpp @@ -5,7 +5,7 @@ // Modified by: VZ at 25.02.00: type safe hashes with WX_DECLARE_HASH() // Created: 01/02/97 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem +// Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -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 // ---------------------------------------------------------------------------- @@ -469,7 +493,7 @@ wxObject *wxHashTable::Get (long key, long value) const { wxNode *node = hash_table[position]->Find (value); if (node) - return node->Data (); + return node->GetData (); else return (wxObject *) NULL; } @@ -489,7 +513,7 @@ wxObject *wxHashTable::Get (long key, const wxChar *value) const { wxNode *node = hash_table[position]->Find (value); if (node) - return node->Data (); + return node->GetData (); else return (wxObject *) NULL; } @@ -508,7 +532,7 @@ wxObject *wxHashTable::Get (long key) const else { wxNode *node = hash_table[position]->Find (k); - return node ? node->Data () : (wxObject*)NULL; + return node ? node->GetData () : (wxObject*)NULL; } } @@ -522,7 +546,7 @@ wxObject *wxHashTable::Get (const wxChar *key) const else { wxNode *node = hash_table[position]->Find (key); - return node ? node->Data () : (wxObject*)NULL; + return node ? node->GetData () : (wxObject*)NULL; } } @@ -541,7 +565,7 @@ wxObject *wxHashTable::Delete (long key) wxNode *node = hash_table[position]->Find (k); if (node) { - wxObject *data = node->Data (); + wxObject *data = node->GetData (); delete node; m_count--; return data; @@ -563,7 +587,7 @@ wxObject *wxHashTable::Delete (const wxChar *key) wxNode *node = hash_table[position]->Find (key); if (node) { - wxObject *data = node->Data (); + wxObject *data = node->GetData (); delete node; m_count--; return data; @@ -588,7 +612,7 @@ wxObject *wxHashTable::Delete (long key, int value) wxNode *node = hash_table[position]->Find (value); if (node) { - wxObject *data = node->Data (); + wxObject *data = node->GetData (); delete node; m_count--; return data; @@ -610,7 +634,7 @@ wxObject *wxHashTable::Delete (long key, const wxChar *value) wxNode *node = hash_table[position]->Find (value); if (node) { - wxObject *data = node->Data (); + wxObject *data = node->GetData (); delete node; m_count--; return data; @@ -655,14 +679,14 @@ wxNode *wxHashTable::Next () { if (hash_table[current_position]) { - current_node = hash_table[current_position]->First (); + current_node = hash_table[current_position]->GetFirst (); found = current_node; } } } else { - current_node = current_node->Next (); + current_node = current_node->GetNext (); found = current_node; } }