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:
@ -32,8 +32,9 @@
|
||||
#define NAV_UTILS_H
|
||||
|
||||
#include "core/math/vector3.h"
|
||||
#include "core/templates/hash_map.h"
|
||||
#include "core/templates/hashfuncs.h"
|
||||
#include "core/templates/vector.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class NavRegion;
|
||||
@ -49,15 +50,18 @@ union PointKey {
|
||||
};
|
||||
|
||||
uint64_t key = 0;
|
||||
bool operator<(const PointKey &p_key) const { return key < p_key.key; }
|
||||
};
|
||||
|
||||
struct EdgeKey {
|
||||
PointKey a;
|
||||
PointKey b;
|
||||
|
||||
bool operator<(const EdgeKey &p_key) const {
|
||||
return (a.key == p_key.a.key) ? (b.key < p_key.b.key) : (a.key < p_key.a.key);
|
||||
static uint32_t hash(const EdgeKey &p_val) {
|
||||
return hash_one_uint64(p_val.a.key) ^ hash_one_uint64(p_val.b.key);
|
||||
}
|
||||
|
||||
bool operator==(const EdgeKey &p_key) const {
|
||||
return (a.key == p_key.a.key) && (b.key == p_key.b.key);
|
||||
}
|
||||
|
||||
EdgeKey(const PointKey &p_a = PointKey(), const PointKey &p_b = PointKey()) :
|
||||
|
||||
Reference in New Issue
Block a user