aco/util: Add aco::unordered_set

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38281>
This commit is contained in:
Natalie Vock 2025-02-17 18:42:47 +01:00 committed by Marge Bot
parent 0cfabe0613
commit 93a5919cee

View file

@ -21,6 +21,7 @@
#include <memory>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>
namespace aco {
@ -391,6 +392,14 @@ template <class Key, class T, class Hash = std::hash<Key>, class Pred = std::equ
using unordered_map =
std::unordered_map<Key, T, Hash, Pred, aco::monotonic_allocator<std::pair<const Key, T>>>;
/*
* aco::unordered_set - alias for std::unordered_set with monotonic_allocator
*
* This template specialization mimics std::pmr::unordered_set.
*/
template <class T, class Hash = std::hash<T>, class Pred = std::equal_to<T>>
using unordered_set = std::unordered_set<T, Hash, Pred, aco::monotonic_allocator<T>>;
/*
* Cache-friendly set of 32-bit IDs with fast insert/erase/lookup and
* the ability to efficiently iterate over contained elements.