#else // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP)
-#include <stddef.h> // for ptrdiff_t
#ifdef __WXWINCE__
typedef int ptrdiff_t;
+#else
+#include <stddef.h> // for ptrdiff_t
#endif
// private
value_type m_value; \
}; \
\
- struct Iterator; \
- friend struct Iterator; \
+ CLASSEXP Iterator; \
+ friend CLASSEXP Iterator; \
protected: \
static void DeleteNode( _wxHashTable_NodeBase* node ) \
{ \
/* */ \
/* forward iterator */ \
/* */ \
- struct Iterator \
+ CLASSEXP Iterator \
{ \
+ public: \
Node* m_node; \
Self* m_ht; \
\
}; \
\
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; } \
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 ) {} \
} \
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; \
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 ) \
{\
{ \
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() ) \
\
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 \
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 ); } \