From 4e67bfc7a40d674037d7b0b5d5b57a9d062c2ddf Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 27 Oct 1999 23:33:05 +0000 Subject: [PATCH] added copy ctor to wxHashTable git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4232 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/hash.h | 5 +++++ src/common/hash.cpp | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/wx/hash.h b/include/wx/hash.h index ec71b9b8c1..4634f96313 100644 --- a/include/wx/hash.h +++ b/include/wx/hash.h @@ -41,6 +41,11 @@ class WXDLLEXPORT wxHashTable: public wxObject wxHashTable(int the_key_type = wxKEY_INTEGER, int size = 1000); ~wxHashTable(void); + // copy ctor and assignment operator + wxHashTable(const wxHashTable& table) { DoCopy(table); } + wxHashTable& operator=(const wxHashTable& table) { Clear(); DoCopy(table); return *this; } + void DoCopy(const wxHashTable& table); + void Destroy(void); // Robert Roebling bool Create(int the_key_type = wxKEY_INTEGER, int size = 1000); diff --git a/src/common/hash.cpp b/src/common/hash.cpp index 691d70832c..330f4b990a 100644 --- a/src/common/hash.cpp +++ b/src/common/hash.cpp @@ -78,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 -- 2.45.2