]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/hashmap.h
Added wxToggleButton handler
[wxWidgets.git] / include / wx / hashmap.h
index 95314ada5a1f05c23207e87c0e091cbff542c7a0..8cc00b57b974d9e4a4adbf1b9b3092e2449929c2 100644 (file)
@@ -143,8 +143,8 @@ public: \
         value_type m_value; \
     }; \
  \
-    struct Iterator; \
-    friend struct Iterator; \
+    CLASSEXP Iterator; \
+    friend CLASSEXP Iterator; \
 protected: \
     static void DeleteNode( _wxHashTable_NodeBase* node ) \
     { \
@@ -154,8 +154,9 @@ public: \
     /*                  */ \
     /* forward iterator */ \
     /*                  */ \
-    struct Iterator \
+    CLASSEXP Iterator \
     { \
+    public: \
         Node* m_node; \
         Self* m_ht; \
  \
@@ -186,8 +187,9 @@ public: \
     }; \
  \
 public: \
-    struct iterator:public Iterator \
+    CLASSEXP iterator : public Iterator \
     { \
+    public: \
         iterator() : Iterator() {} \
         iterator( Node* node, Self* ht ) : Iterator( node, ht ) {} \
         iterator& operator++() { PlusPlus(); return *this; } \
@@ -196,8 +198,9 @@ public: \
         pointer operator ->() const { return &(m_node->m_value); } \
     }; \
  \
-    struct const_iterator:public Iterator \
+    CLASSEXP const_iterator : public Iterator \
     { \
+    public: \
         const_iterator() : Iterator() {} \
         const_iterator( Node* node, const Self* ht ) \
             : Iterator( node, (Self*)ht ) {} \
@@ -295,7 +298,7 @@ protected: \
     } \
     static Node* CopyNode( Node* node ) { return new Node( *node ); } \
  \
-    Node* GetOrCreateNode( const value_type& value ) \
+    Node* GetOrCreateNode( const value_type& value, bool& created ) \
     { \
         const const_key_type& key = m_getKey( value ); \
         size_t bucket = m_hasher( key ) % m_tableBuckets; \
@@ -304,10 +307,14 @@ protected: \
         while( node ) \
         { \
             if( m_equals( m_getKey( node->m_value ), key ) ) \
+            { \
+                created = false; \
                 return node; \
+            } \
             node = node->m_next(); \
         } \
-       return CreateNode( value  , bucket); \
+        created = true; \
+        return CreateNode( value, bucket); \
     }\
     Node * CreateNode( const value_type& value, size_t bucket ) \
     {\
@@ -570,6 +577,7 @@ CLASSEXP CLASSNAME:public CLASSNAME##_wxImplementation_HashTable \
 { \
 public: \
     typedef VALUE_T mapped_type; \
+    _WX_DECLARE_PAIR( iterator, bool, Insert_Result, CLASSEXP ) \
  \
     wxEXPLICIT CLASSNAME( size_type hint = 100, hasher hf = hasher(),        \
                           key_equal eq = key_equal() )                       \
@@ -578,7 +586,10 @@ public: \
  \
     mapped_type& operator[]( const const_key_type& key ) \
     { \
-        return GetOrCreateNode( CLASSNAME##_wxImplementation_Pair( key, mapped_type() ) )->m_value.second; \
+        bool created; \
+        return GetOrCreateNode( \
+                CLASSNAME##_wxImplementation_Pair( key, mapped_type() ), \
+                created)->m_value.second; \
     } \
  \
     const_iterator find( const const_key_type& key ) const \
@@ -591,7 +602,16 @@ public: \
         return iterator( GetNode( key ), this ); \
     } \
  \
-    void insert( const value_type& v ) { (*this)[v.first] = v.second; } \
+    Insert_Result insert( const value_type& v ) \
+    { \
+        bool created; \
+        Node *node = GetOrCreateNode( \
+                CLASSNAME##_wxImplementation_Pair( v.first, v.second ), \
+                created); \
+        if ( !created ) \
+            node->m_value.second = v.second; \
+        return Insert_Result(iterator(node, this), created); \
+    } \
  \
     size_type erase( const key_type& k ) \
         { return CLASSNAME##_wxImplementation_HashTable::erase( k ); } \