mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case. * Replaced by the new HashMap. * Renamed Map to RBMap and Set to RBSet for cases that still make sense (order matters) but use is discouraged. There were very few cases where replacing by HashMap was undesired because keeping the key order was intended. I tried to keep those (as RBMap) as much as possible, but might have missed some. Review appreciated!
This commit is contained in:
@@ -31,8 +31,8 @@
|
||||
#ifndef PAIR_H
|
||||
#define PAIR_H
|
||||
|
||||
#include "core/templates/hashfuncs.h"
|
||||
#include "core/typedefs.h"
|
||||
|
||||
template <class F, class S>
|
||||
struct Pair {
|
||||
F first;
|
||||
@@ -69,6 +69,15 @@ struct PairSort {
|
||||
}
|
||||
};
|
||||
|
||||
template <class F, class S>
|
||||
struct PairHash {
|
||||
static uint32_t hash(const Pair<F, S> &P) {
|
||||
uint64_t h1 = HashMapHasherDefault::hash(P.first);
|
||||
uint64_t h2 = HashMapHasherDefault::hash(P.second);
|
||||
return hash_one_uint64((h1 << 32) | h2);
|
||||
}
|
||||
};
|
||||
|
||||
template <class K, class V>
|
||||
struct KeyValue {
|
||||
const K key;
|
||||
|
||||
Reference in New Issue
Block a user