- // Should NEVER be
- long k = (long) key;
- if (k < 0)
- k = -k;
-
- int position = (int) (k % n);
- if (!hash_table[position])
- {
- hash_table[position] = new wxList (wxKEY_INTEGER);
- if (m_deleteContents) hash_table[position]->DeleteContents(TRUE);
- }
-
- hash_table[position]->Append (value, object);
- m_count++;
+ size_t bucket = ( m_keyType == wxKEY_INTEGER ?
+ node->m_key.integer :
+ MakeKey( *node->m_key.string ) ) % m_size;
+
+ if( node->GetNext() == node )
+ {
+ // single-node chain (common case)
+ m_table[bucket] = NULL;
+ }
+ else
+ {
+ Node *start = m_table[bucket], *curr;
+ Node* prev = start;
+
+ for( curr = prev->GetNext(); curr != node;
+ prev = curr, curr = curr->GetNext() ) ;
+
+ DoUnlinkNode( bucket, node, prev );
+ }
+
+ DoDestroyNode( node );