diff --git a/AK/HashMap.h b/AK/HashMap.h index bd58a5a8e6..1ecd5e554d 100644 --- a/AK/HashMap.h +++ b/AK/HashMap.h @@ -34,19 +34,6 @@ private: public: HashMap() {} - HashMap(HashMap&& other) - : m_table(move(other.m_table)) - { - } - - HashMap& operator=(HashMap&& other) - { - if (this != &other) { - m_table = move(other.m_table); - } - return *this; - } - bool is_empty() const { return m_table.is_empty(); } int size() const { return m_table.size(); } int capacity() const { return m_table.capacity(); } diff --git a/AK/HashTable.h b/AK/HashTable.h index 7720a38f86..78ef573b69 100644 --- a/AK/HashTable.h +++ b/AK/HashTable.h @@ -22,7 +22,23 @@ private: public: HashTable() {} - explicit HashTable(HashTable&& other) + HashTable(const HashTable& other) + { + ensure_capacity(other.size()); + for (auto& it : other) + set(it); + } + HashTable& operator=(const HashTable& other) + { + if (this != &other) { + clear(); + ensure_capacity(other.size()); + for (auto& it : other) + set(it); + } + return *this; + } + HashTable(HashTable&& other) : m_buckets(other.m_buckets) , m_size(other.m_size) , m_capacity(other.m_capacity)