Explorar o código

Backported the oa_hashmap lookup_ptr function

AndreaCatania %!s(int64=3) %!d(string=hai) anos
pai
achega
62e9044837
Modificáronse 1 ficheiros con 20 adicións e 0 borrados
  1. 20 0
      core/oa_hash_map.h

+ 20 - 0
core/oa_hash_map.h

@@ -237,6 +237,26 @@ public:
 		return false;
 	}
 
+	const TValue *lookup_ptr(const TKey &p_key) const {
+		uint32_t pos = 0;
+		bool exists = _lookup_pos(p_key, pos);
+
+		if (exists) {
+			return &values[pos];
+		}
+		return nullptr;
+	}
+
+	TValue *lookup_ptr(const TKey &p_key) {
+		uint32_t pos = 0;
+		bool exists = _lookup_pos(p_key, pos);
+
+		if (exists) {
+			return &values[pos];
+		}
+		return nullptr;
+	}
+
 	_FORCE_INLINE_ bool has(const TKey &p_key) const {
 		uint32_t _pos = 0;
 		return _lookup_pos(p_key, _pos);