utils: Add HASH template parameter to UniqueVector
Defaults to std::hash. Change-Id: I99cc545ce8651f9e4f92fc5ba3f1ffdb3f5de289 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60208 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
8f271f4cf8
commit
669c57f3d1
|
@ -22,7 +22,7 @@ namespace tint {
|
||||||
|
|
||||||
/// UniqueVector is an ordered container that only contains unique items.
|
/// UniqueVector is an ordered container that only contains unique items.
|
||||||
/// Attempting to add a duplicate is a no-op.
|
/// Attempting to add a duplicate is a no-op.
|
||||||
template <typename T>
|
template <typename T, typename HASH = std::hash<T>>
|
||||||
struct UniqueVector {
|
struct UniqueVector {
|
||||||
/// The iterator returned by begin() and end()
|
/// The iterator returned by begin() and end()
|
||||||
using ConstIterator = typename std::vector<T>::const_iterator;
|
using ConstIterator = typename std::vector<T>::const_iterator;
|
||||||
|
@ -55,7 +55,7 @@ struct UniqueVector {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<T> vector;
|
std::vector<T> vector;
|
||||||
std::unordered_set<T> set;
|
std::unordered_set<T, HASH> set;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
Loading…
Reference in New Issue