X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/17d8ee1cbd0486321f1dbb8b5a1ff094ef3ef9ba..c0eba78b86232bf8c2ef886e0a35808ab09df25f:/src/common/hash.cpp?ds=sidebyside diff --git a/src/common/hash.cpp b/src/common/hash.cpp index 3c514d498c..5110f8228c 100644 --- a/src/common/hash.cpp +++ b/src/common/hash.cpp @@ -36,6 +36,8 @@ wxHashTable::wxHashTable (int the_key_type, int size) n = 0; hash_table = (wxList**) NULL; Create(the_key_type, size); + m_count = 0; + m_deleteContents = FALSE; /* n = size; current_position = -1; @@ -109,9 +111,13 @@ void wxHashTable::Put (long key, long value, wxObject * object) int position = (int) (k % n); if (!hash_table[position]) + { hash_table[position] = new wxList (wxKEY_INTEGER); + if (m_deleteContents) hash_table[position]->DeleteContents(TRUE); + } hash_table[position]->Append (value, object); + m_count++; } void wxHashTable::Put (long key, const wxChar *value, wxObject * object) @@ -123,9 +129,13 @@ void wxHashTable::Put (long key, const wxChar *value, wxObject * object) int position = (int) (k % n); if (!hash_table[position]) + { hash_table[position] = new wxList (wxKEY_INTEGER); + if (m_deleteContents) hash_table[position]->DeleteContents(TRUE); + } hash_table[position]->Append (value, object); + m_count++; } void wxHashTable::Put (long key, wxObject * object) @@ -137,9 +147,13 @@ void wxHashTable::Put (long key, wxObject * object) int position = (int) (k % n); if (!hash_table[position]) + { hash_table[position] = new wxList (wxKEY_INTEGER); - + if (m_deleteContents) hash_table[position]->DeleteContents(TRUE); + } + hash_table[position]->Append (k, object); + m_count++; } void wxHashTable::Put (const wxChar *key, wxObject * object) @@ -147,9 +161,13 @@ void wxHashTable::Put (const wxChar *key, wxObject * object) int position = (int) (MakeKey (key) % n); if (!hash_table[position]) + { hash_table[position] = new wxList (wxKEY_STRING); + if (m_deleteContents) hash_table[position]->DeleteContents(TRUE); + } hash_table[position]->Append (key, object); + m_count++; } wxObject *wxHashTable::Get (long key, long value) const @@ -239,6 +257,7 @@ wxObject *wxHashTable::Delete (long key) { wxObject *data = node->Data (); delete node; + m_count--; return data; } else @@ -258,6 +277,7 @@ wxObject *wxHashTable::Delete (const wxChar *key) { wxObject *data = node->Data (); delete node; + m_count--; return data; } else @@ -282,6 +302,7 @@ wxObject *wxHashTable::Delete (long key, int value) { wxObject *data = node->Data (); delete node; + m_count--; return data; } else @@ -301,6 +322,7 @@ wxObject *wxHashTable::Delete (long key, const wxChar *value) { wxObject *data = node->Data (); delete node; + m_count--; return data; } else @@ -360,6 +382,7 @@ wxNode *wxHashTable::Next (void) void wxHashTable::DeleteContents (bool flag) { int i; + m_deleteContents = flag; for (i = 0; i < n; i++) { if (hash_table[i]) @@ -375,5 +398,6 @@ void wxHashTable::Clear (void) if (hash_table[i]) hash_table[i]->Clear (); } + m_count = 0; }