martinus / unordered_dense

A fast & densely stored hashmap and hashset based on robin-hood backward shift deletion
MIT License
898 stars 72 forks source link

add values() API for xvalues #121

Closed lrita closed 2 months ago

lrita commented 2 months ago

We can use values() API to get the finally underlying vector in some efficient scenes:

auto map = map_t();
for (...) map.emplace(...);
auto vec = std::move(map).values();
std::sort(vec.begin(), vec.end(), [](...) { ... });
if (vec.size() > topn) vec.resize(topn);
for (auto &v : vec) ...;
glebm commented 2 months ago

There is already std::move(map).extract():

https://github.com/martinus/unordered_dense/blob/d911053e390816ecc5dedd5a9d6b4bb5ed92b4c9/include/ankerl/unordered_dense.h#L1411-L1415