BAN: Make hashmap work with non-copy constructable values
This commit is contained in:
parent
6fec142760
commit
b833239a82
|
@ -130,9 +130,7 @@ namespace BAN
|
||||||
ASSERT(!contains(key));
|
ASSERT(!contains(key));
|
||||||
TRY(rebucket(m_size + 1));
|
TRY(rebucket(m_size + 1));
|
||||||
auto& bucket = get_bucket(key);
|
auto& bucket = get_bucket(key);
|
||||||
auto result = bucket.emplace_back(key, forward<Args>(args)...);
|
TRY(bucket.emplace_back(key, forward<Args>(args)...));
|
||||||
if (result.is_error())
|
|
||||||
return Error::from_errno(ENOMEM);
|
|
||||||
m_size++;
|
m_size++;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -220,8 +218,7 @@ namespace BAN
|
||||||
|
|
||||||
size_type new_bucket_count = BAN::Math::max<size_type>(bucket_count, m_buckets.size() * 2);
|
size_type new_bucket_count = BAN::Math::max<size_type>(bucket_count, m_buckets.size() * 2);
|
||||||
Vector<LinkedList<Entry>> new_buckets;
|
Vector<LinkedList<Entry>> new_buckets;
|
||||||
if (new_buckets.resize(new_bucket_count).is_error())
|
TRY(new_buckets.resize(new_bucket_count));
|
||||||
return Error::from_errno(ENOMEM);
|
|
||||||
|
|
||||||
for (auto& bucket : m_buckets)
|
for (auto& bucket : m_buckets)
|
||||||
{
|
{
|
||||||
|
@ -231,7 +228,7 @@ namespace BAN
|
||||||
if constexpr(STABLE)
|
if constexpr(STABLE)
|
||||||
TRY(new_buckets[bucket_index].push_back(entry));
|
TRY(new_buckets[bucket_index].push_back(entry));
|
||||||
else
|
else
|
||||||
TRY(new_buckets[bucket_index].push_back(BAN::move(entry)));
|
TRY(new_buckets[bucket_index].push_back(move(entry)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue