+// defines a new type safe hash table which stores the elements of type eltype
+// in lists of class listclass
+#define _WX_DECLARE_HASH(eltype, listclass, hashclass, classexp) \
+ classexp hashclass : public wxHashTableBase \
+ { \
+ public: \
+ hashclass(wxKeyType keyType = wxKEY_INTEGER, \
+ size_t size = wxHASH_SIZE_DEFAULT) \
+ { Create(keyType, size); } \
+ \
+ ~hashclass() { Destroy(); } \
+ \
+ void Put(long key, long val, eltype *data) { DoPut(key, val, data); } \
+ void Put(long key, eltype *data) { DoPut(key, key, data); } \
+ \
+ eltype *Get(long key, long value) const \
+ { \
+ wxNodeBase *node = GetNode(key, value); \
+ return node ? ((listclass::Node *)node)->GetData() : (eltype *)0; \
+ } \
+ eltype *Get(long key) const { return Get(key, key); } \
+ \
+ eltype *Delete(long key, long value) \
+ { \
+ eltype *data; \
+ \
+ wxNodeBase *node = GetNode(key, value); \
+ if ( node ) \
+ { \
+ data = ((listclass::Node *)node)->GetData(); \
+ \
+ delete node; \
+ m_count--; \
+ } \
+ else \
+ { \
+ data = (eltype *)0; \
+ } \
+ \
+ return data; \
+ } \
+ eltype *Delete(long key) { return Delete(key, key); } \
+ \
+ protected: \
+ void DoPut(long key, long value, eltype *data) \
+ { \
+ size_t slot = (size_t)abs((int)(key % (long)m_hashSize)); \
+ \
+ if ( !m_hashTable[slot] ) \
+ { \
+ m_hashTable[slot] = new listclass(m_keyType); \
+ if ( m_deleteContents ) \
+ m_hashTable[slot]->DeleteContents(TRUE); \
+ } \
+ \
+ ((listclass *)m_hashTable[slot])->Append(value, data); \
+ m_count++; \
+ } \
+ }
+
+// this macro is to be used in the user code
+#define WX_DECLARE_HASH(el, list, hash) \
+ _WX_DECLARE_HASH(el, list, hash, class)
+
+// and this one does exactly the same thing but should be used inside the
+// library
+#define WX_DECLARE_EXPORTED_HASH(el, list, hash) \
+ _WX_DECLARE_HASH(el, list, hash, class WXDLLEXPORT)
+
+#define WX_DECLARE_USER_EXPORTED_HASH(el, list, hash, usergoo) \
+ _WX_DECLARE_HASH(el, list, hash, class usergoo)
+