X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c67daf87774c71ae9f73af9969008af220e52a11..61f0d452ea7e47fea18d0ab748095dc42d7dd66d:/src/common/hash.cpp diff --git a/src/common/hash.cpp b/src/common/hash.cpp index f4139dd5f9..330f4b990a 100644 --- a/src/common/hash.cpp +++ b/src/common/hash.cpp @@ -48,11 +48,18 @@ wxHashTable::wxHashTable (int the_key_type, int size) wxHashTable::~wxHashTable (void) { + Destroy(); +} + +void wxHashTable::Destroy(void) +{ + if (!hash_table) return; int i; for (i = 0; i < n; i++) if (hash_table[i]) delete hash_table[i]; delete[] hash_table; + hash_table = NULL; } bool wxHashTable::Create(int the_key_type, int size) @@ -71,6 +78,25 @@ bool wxHashTable::Create(int the_key_type, int size) 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 @@ -85,7 +111,7 @@ void wxHashTable::Put (long key, long value, wxObject * object) hash_table[position]->Append (value, object); } -void wxHashTable::Put (long key, const char *value, wxObject * object) +void wxHashTable::Put (long key, const wxChar *value, wxObject * object) { // Should NEVER be long k = (long) key; @@ -113,7 +139,7 @@ void wxHashTable::Put (long key, wxObject * object) hash_table[position]->Append (k, object); } -void wxHashTable::Put (const char *key, wxObject * object) +void wxHashTable::Put (const wxChar *key, wxObject * object) { int position = (int) (MakeKey (key) % n); @@ -143,7 +169,7 @@ wxObject *wxHashTable::Get (long key, long value) const } } -wxObject *wxHashTable::Get (long key, const char *value) const +wxObject *wxHashTable::Get (long key, const wxChar *value) const { // Should NEVER be long k = (long) key; @@ -180,7 +206,7 @@ wxObject *wxHashTable::Get (long key) const } } -wxObject *wxHashTable::Get (const char *key) const +wxObject *wxHashTable::Get (const wxChar *key) const { int position = (int) (MakeKey (key) % n); @@ -217,7 +243,7 @@ wxObject *wxHashTable::Delete (long key) } } -wxObject *wxHashTable::Delete (const char *key) +wxObject *wxHashTable::Delete (const wxChar *key) { int position = (int) (MakeKey (key) % n); if (!hash_table[position]) @@ -260,7 +286,7 @@ wxObject *wxHashTable::Delete (long key, int value) } } -wxObject *wxHashTable::Delete (long key, const char *value) +wxObject *wxHashTable::Delete (long key, const wxChar *value) { int position = (int) (key % n); if (!hash_table[position]) @@ -279,12 +305,12 @@ wxObject *wxHashTable::Delete (long key, const char *value) } } -long wxHashTable::MakeKey (const char *string) const +long wxHashTable::MakeKey (const wxChar *string) const { long int_key = 0; while (*string) - int_key += (unsigned char) *string++; + int_key += (wxUChar) *string++; return int_key; }