mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:24:57 +00:00
AK: Make it possible to move and copy HashMap and HashTable.
Previously it was only possible to move them, but we should allow copying as well, since it's gonna be useful for many things.
This commit is contained in:
parent
009b9bfd10
commit
2c1c4ab116
2 changed files with 17 additions and 14 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue