New wxHashTable implementation when wxUSE_STL == 1. Replaces

the old implementation based upon wxHashMap. Removed support
for wxHashTable in wxHashMap.
  Rationale: using wxHashMap for wxHashTable implementation required
special support in wxHashMap. This precluded using STL-provided
hash_map to implement wxHashMap. This new implementation does not
use keyed wxList interface and should be almost totally compatible
with the old non-STL wxHashTable.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24638 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mattia Barbon
2003-11-23 08:12:34 +00:00
parent ff9ca1fd6f
commit 1a6d9c7680
6 changed files with 631 additions and 268 deletions

View File

@@ -128,20 +128,9 @@ void _wxHashTableBase2::CopyHashTable( _wxHashTable_NodeBase** srcTable,
size_t srcBuckets,
_wxHashTableBase2* dst,
_wxHashTable_NodeBase** dstTable,
size_t dstBuckets,
BucketFromNode func, ProcessNode proc )
{
// for compatibility with wxHashTable (to avoid reimplementig it
// from scratch), we need to preserve the order of nodes in a
// source bucket when copying the table, hence, to avoid
// allocating an auxiliary table we use a circular list for each
// bucket, and we keep the *tail* of each list in dstTable[i], to
// be able to append nodes in O(1) time. Wen we're done copying,
// we adjust dstTable[i] to point at the head of the list and we
// break the circular list into a linear one.
size_t i;
for( i = 0; i < srcBuckets; ++i )
for( size_t i = 0; i < srcBuckets; ++i )
{
_wxHashTable_NodeBase* nextnode;
@@ -151,24 +140,8 @@ void _wxHashTableBase2::CopyHashTable( _wxHashTable_NodeBase** srcTable,
nextnode = node->m_nxt;
_wxHashTable_NodeBase* newnode = proc( node );
if( dstTable[bucket] )
{
newnode->m_nxt = dstTable[bucket]->m_nxt; // head of the list
dstTable[bucket]->m_nxt = newnode;
dstTable[bucket] = newnode;
}
else
dstTable[bucket] = newnode->m_nxt = newnode;
}
}
for( i = 0; i < dstBuckets; ++i )
{
if( dstTable[i] )
{
_wxHashTable_NodeBase* tmp = dstTable[i];
dstTable[i] = dstTable[i]->m_nxt;
tmp->m_nxt = NULL;
newnode->m_nxt = dstTable[bucket];
dstTable[bucket] = newnode;
}
}
}