#include <stddef.h> // for ptrdiff_t
// private
-struct WXDLLEXPORT _wxHashTable_NodeBase
+struct WXDLLIMPEXP_BASE _wxHashTable_NodeBase
{
_wxHashTable_NodeBase() : m_nxt(0) {}
};
// private
-class WXDLLEXPORT _wxHashTableBase2
+class WXDLLIMPEXP_BASE _wxHashTableBase2
{
public:
typedef void (*NodeDtor)(_wxHashTable_NodeBase*);
return node; \
node = node->m_next(); \
} \
- \
- node = new Node( value ); \
+ return CreateNode( value , bucket); \
+ }\
+ Node * CreateNode( const value_type& value, size_t bucket ) \
+ {\
+ Node* node = new Node( value ); \
node->m_nxt = m_table[bucket]; \
m_table[bucket] = node; \
\
\
return node; \
} \
+ void CreateNode( const value_type& value ) \
+ {\
+ CreateNode(value, m_hasher( m_getKey(value) ) % m_tableBuckets ); \
+ }\
\
/* returns NULL if not found */ \
Node** GetNodePtr( const const_key_type& key ) const \
// in the hash table class assignment operator (where they're assigned)
// integer types
-class WXDLLEXPORT wxIntegerHash
+class WXDLLIMPEXP_BASE wxIntegerHash
{
public:
wxIntegerHash() { }
wxIntegerHash& operator=(const wxIntegerHash&) { return *this; }
};
-class WXDLLEXPORT wxIntegerEqual
+class WXDLLIMPEXP_BASE wxIntegerEqual
{
public:
wxIntegerEqual() { }
};
// pointers
-class WXDLLEXPORT wxPointerHash
+class WXDLLIMPEXP_BASE wxPointerHash
{
public:
wxPointerHash() { }
wxPointerHash& operator=(const wxPointerHash&) { return *this; }
};
-class WXDLLEXPORT wxPointerEqual
+class WXDLLIMPEXP_BASE wxPointerEqual
{
public:
wxPointerEqual() { }
};
// wxString, char*, wxChar*
-class WXDLLEXPORT wxStringHash
+class WXDLLIMPEXP_BASE wxStringHash
{
public:
wxStringHash() {}
wxStringHash& operator=(const wxStringHash&) { return *this; }
};
-class WXDLLEXPORT wxStringEqual
+class WXDLLIMPEXP_BASE wxStringEqual
{
public:
wxStringEqual() {}
_WX_DECLARE_HASH_MAP( void*, VALUE_T, wxPointerHash, wxPointerEqual, \
CLASSNAME, class WXDLLEXPORT )
+// delete all hash elements
+//
+// NB: the class declaration of the hash elements must be visible from the
+// place where you use this macro, otherwise the proper destructor may not
+// be called (a decent compiler should give a warning about it, but don't
+// count on it)!
+#define WX_CLEAR_HASH_MAP(type, hashmap) \
+ { \
+ type##::iterator it, en; \
+ for( it = (hashmap).begin(), en = (hashmap).end(); it != en; ++it ) \
+ delete it->second; \
+ (hashmap).clear(); \
+ }
+
#endif // _WX_HASHMAP_H_