#include <string.h>
#include <stdarg.h>
-#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxHashTable, wxObject)
-#endif
wxHashTable::wxHashTable (int the_key_type, int size)
{
+ n = 0;
+ hash_table = (wxList**) NULL;
+ Create(the_key_type, size);
+/*
n = size;
current_position = -1;
current_node = (wxNode *) NULL;
int i;
for (i = 0; i < size; i++)
hash_table[i] = (wxList *) NULL;
+*/
}
wxHashTable::~wxHashTable (void)
bool wxHashTable::Create(int the_key_type, int size)
{
+ Destroy();
+
n = size;
current_position = -1;
current_node = (wxNode *) NULL;
key_type = the_key_type;
- if (hash_table)
- delete[] hash_table;
hash_table = new wxList *[size];
int i;
for (i = 0; i < size; i++)
return TRUE;
}
+
+void wxHashTable::DoCopy(const wxHashTable& table)
+{
+ n = table.n;
+ current_position = table.current_position;
+ current_node = NULL; // doesn't matter - Next() will reconstruct it
+ key_type = table.key_type;
+
+ hash_table = new wxList *[n];
+ for (int i = 0; i < n; i++) {
+ if (table.hash_table[i] == NULL)
+ hash_table[i] = NULL;
+ else {
+ hash_table[i] = new wxList(key_type);
+ *(hash_table[i]) = *(table.hash_table[i]);
+ }
+ }
+}
+
void wxHashTable::Put (long key, long value, wxObject * object)
{
// Should NEVER be