]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/hashmap.h
fixed bug in DeleteEntry()
[wxWidgets.git] / include / wx / hashmap.h
index 5924d715761ae729aa59da7c51fbc1a1e21bd0c8..3f2e00897691fd4a545cdb9a92c2ab57b25f8a04 100644 (file)
@@ -70,6 +70,7 @@ protected:
     static void CopyHashTable( _wxHashTable_NodeBase** srcTable,
                                size_t srcBuckets, _wxHashTableBase2* dst,
                                _wxHashTable_NodeBase** dstTable,
     static void CopyHashTable( _wxHashTable_NodeBase** srcTable,
                                size_t srcBuckets, _wxHashTableBase2* dst,
                                _wxHashTable_NodeBase** dstTable,
+                               size_t dstBuckets,
                                BucketFromNode func, ProcessNode proc );
 
     static void** AllocTable( size_t sz )
                                BucketFromNode func, ProcessNode proc );
 
     static void** AllocTable( size_t sz )
@@ -297,6 +298,19 @@ protected: \
  \
         return node; \
     } \
  \
         return node; \
     } \
+    void CreateNodeLast( const value_type& value )                           \
+    {                                                                        \
+        size_t bucket = m_hasher( m_getKey(value) ) % m_tableBuckets;        \
+        Node* curr = m_table[bucket],                                        \
+            * next = m_table[bucket];                                        \
+        while( next ) { curr = next; next = next->m_next(); }                \
+        Node** ptr = curr ? (Node**)&curr->m_nxt : &m_table[bucket];         \
+        *ptr = new Node( value );                                            \
+        /* must be after the node is inserted */                             \
+        ++m_items;                                                           \
+        if( SHOULD_GROW( m_tableBuckets, m_items ) )                         \
+            ResizeTable( m_tableBuckets );                                   \
+    }                                                                        \
     void CreateNode( const value_type& value ) \
     {\
         CreateNode(value, m_hasher( m_getKey(value) ) % m_tableBuckets ); \
     void CreateNode( const value_type& value ) \
     {\
         CreateNode(value, m_hasher( m_getKey(value) ) % m_tableBuckets ); \
@@ -344,7 +358,7 @@ protected: \
         m_tableBuckets = newSize; \
  \
         CopyHashTable( (_wxHashTable_NodeBase**)srcTable, srcBuckets, \
         m_tableBuckets = newSize; \
  \
         CopyHashTable( (_wxHashTable_NodeBase**)srcTable, srcBuckets, \
-                       this, (_wxHashTable_NodeBase**)m_table, \
+                       this, (_wxHashTable_NodeBase**)m_table, newSize, \
                        (BucketFromNode)GetBucketForNode,\
                        (ProcessNode)&DummyProcessNode ); \
         free(srcTable); \
                        (BucketFromNode)GetBucketForNode,\
                        (ProcessNode)&DummyProcessNode ); \
         free(srcTable); \
@@ -356,7 +370,7 @@ protected: \
         ResizeTable( ht.size() ); \
         CopyHashTable( (_wxHashTable_NodeBase**)ht.m_table, ht.m_tableBuckets,\
                        (_wxHashTableBase2*)this, \
         ResizeTable( ht.size() ); \
         CopyHashTable( (_wxHashTable_NodeBase**)ht.m_table, ht.m_tableBuckets,\
                        (_wxHashTableBase2*)this, \
-                       (_wxHashTable_NodeBase**)m_table, \
+                       (_wxHashTable_NodeBase**)m_table, m_tableBuckets, \
                        (BucketFromNode)GetBucketForNode, \
                        (ProcessNode)CopyNode ); \
     } \
                        (BucketFromNode)GetBucketForNode, \
                        (ProcessNode)CopyNode ); \
     } \
@@ -511,8 +525,10 @@ CLASSEXP CLASSNAME:public CLASSNAME##_wxImplementation_HashTable \
 public: \
     typedef VALUE_T mapped_type; \
  \
 public: \
     typedef VALUE_T mapped_type; \
  \
-    CLASSNAME( size_type hint = 100, hasher hf = hasher(), key_equal eq = key_equal() ) \
-        : CLASSNAME##_wxImplementation_HashTable( hint, hf, eq, CLASSNAME##_wxImplementation_KeyEx() ) {} \
+    wxEXPLICIT CLASSNAME( size_type hint = 100, hasher hf = hasher(),        \
+                          key_equal eq = key_equal() )                       \
+        : CLASSNAME##_wxImplementation_HashTable( hint, hf, eq,              \
+                                   CLASSNAME##_wxImplementation_KeyEx() ) {} \
  \
     mapped_type& operator[]( const const_key_type& key ) \
     { \
  \
     mapped_type& operator[]( const const_key_type& key ) \
     { \