X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ad81651f00edc6f489d9b6a0839d316a964fd521..c6e62f74fcac5b62889b59e7ce7a41d0ce884d7b:/src/common/hash.cpp diff --git a/src/common/hash.cpp b/src/common/hash.cpp index fbee85aceb..4c6ad97c6d 100644 --- a/src/common/hash.cpp +++ b/src/common/hash.cpp @@ -33,6 +33,11 @@ IMPLEMENT_DYNAMIC_CLASS(wxHashTable, wxObject) wxHashTable::wxHashTable (int the_key_type, int size) { + n = 0; + hash_table = (wxList**) NULL; + Create(the_key_type, size); + m_count = 0; +/* n = size; current_position = -1; current_node = (wxNode *) NULL; @@ -42,6 +47,7 @@ wxHashTable::wxHashTable (int the_key_type, int size) int i; for (i = 0; i < size; i++) hash_table[i] = (wxList *) NULL; +*/ } wxHashTable::~wxHashTable (void) @@ -62,13 +68,13 @@ void wxHashTable::Destroy(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++) @@ -107,6 +113,7 @@ void wxHashTable::Put (long key, long value, wxObject * object) hash_table[position] = new wxList (wxKEY_INTEGER); hash_table[position]->Append (value, object); + m_count++; } void wxHashTable::Put (long key, const wxChar *value, wxObject * object) @@ -121,6 +128,7 @@ void wxHashTable::Put (long key, const wxChar *value, wxObject * object) hash_table[position] = new wxList (wxKEY_INTEGER); hash_table[position]->Append (value, object); + m_count++; } void wxHashTable::Put (long key, wxObject * object) @@ -135,6 +143,7 @@ void wxHashTable::Put (long key, wxObject * object) hash_table[position] = new wxList (wxKEY_INTEGER); hash_table[position]->Append (k, object); + m_count++; } void wxHashTable::Put (const wxChar *key, wxObject * object) @@ -145,6 +154,7 @@ void wxHashTable::Put (const wxChar *key, wxObject * object) hash_table[position] = new wxList (wxKEY_STRING); hash_table[position]->Append (key, object); + m_count++; } wxObject *wxHashTable::Get (long key, long value) const @@ -234,6 +244,7 @@ wxObject *wxHashTable::Delete (long key) { wxObject *data = node->Data (); delete node; + m_count--; return data; } else @@ -253,6 +264,7 @@ wxObject *wxHashTable::Delete (const wxChar *key) { wxObject *data = node->Data (); delete node; + m_count--; return data; } else @@ -277,6 +289,7 @@ wxObject *wxHashTable::Delete (long key, int value) { wxObject *data = node->Data (); delete node; + m_count--; return data; } else @@ -296,6 +309,7 @@ wxObject *wxHashTable::Delete (long key, const wxChar *value) { wxObject *data = node->Data (); delete node; + m_count--; return data; } else @@ -370,5 +384,6 @@ void wxHashTable::Clear (void) if (hash_table[i]) hash_table[i]->Clear (); } + m_count = 0; }