#ifndef _WX_HASHMAP_H_
#define _WX_HASHMAP_H_
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma interface "hashmap.h"
-#endif
-
#include "wx/string.h"
#if (defined(HAVE_EXT_HASH_MAP) || defined(HAVE_HASH_MAP)) \
{
return (void **)calloc(sz, sizeof(void*));
}
+ static void FreeTable(void *table)
+ {
+ free(table);
+ }
};
#define _WX_DECLARE_HASHTABLE( VALUE_T, KEY_T, HASH_T, KEY_EX_T, KEY_EQ_T, CLASSNAME, CLASSEXP, SHOULD_GROW, SHOULD_SHRINK ) \
{ \
clear(); \
\
- free(m_table); \
+ FreeTable(m_table); \
} \
\
hasher hash_funct() { return m_hasher; } \
/* returns NULL if not found */ \
Node** GetNodePtr( const const_key_type& key ) const \
{ \
- unsigned long hash = m_hasher( key ); \
+ unsigned long hash = wx_static_cast(unsigned long, m_hasher( key )); \
Node** node = &m_table[hash % m_tableBuckets]; \
\
while( *node ) \
/* expressing it in terms of GetNodePtr is 5-8% slower :-( */ \
Node* GetNode( const const_key_type& key ) const \
{ \
- unsigned long hash = m_hasher( key ); \
+ unsigned long hash = wx_static_cast(unsigned long, m_hasher( key )); \
Node* node = m_table[hash % m_tableBuckets]; \
\
while( node ) \
this, (_wxHashTable_NodeBase**)m_table, \
(BucketFromNode)GetBucketForNode,\
(ProcessNode)&DummyProcessNode ); \
- free(srcTable); \
+ FreeTable(srcTable); \
} \
\
/* this must be called _after_ m_table has been cleaned */ \
};
// grow/shrink predicates
-inline bool never_grow( size_t, size_t ) { return FALSE; }
-inline bool never_shrink( size_t, size_t ) { return FALSE; }
+inline bool never_grow( size_t, size_t ) { return false; }
+inline bool never_shrink( size_t, size_t ) { return false; }
inline bool grow_lf70( size_t buckets, size_t items )
{
return float(items)/float(buckets) >= 0.85;
public:
wxPointerHash() { }
- // TODO: this might not work well on architectures with 64 bit pointers but
- // 32 bit longs, we should use % ULONG_MAX there
#if wxUSE_STL && defined(HAVE_STL_HASH_MAP)
size_t operator()( const void* k ) const { return (size_t)k; }
#else
- unsigned long operator()( const void* k ) const { return (unsigned long)wxPtrToULong(k); }
+ wxUIntPtr operator()( const void* k ) const { return wxPtrToUInt(k); }
#endif
wxPointerHash& operator=(const wxPointerHash&) { return *this; }