瀏覽代碼

Backported the oa_hashmap lookup_ptr function

AndreaCatania 3 年之前
父節點
當前提交
62e9044837
共有 1 個文件被更改,包括 20 次插入0 次删除
  1. 20 0
      core/oa_hash_map.h

+ 20 - 0
core/oa_hash_map.h

@@ -237,6 +237,26 @@ public:
 		return false;
 		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 {
 	_FORCE_INLINE_ bool has(const TKey &p_key) const {
 		uint32_t _pos = 0;
 		uint32_t _pos = 0;
 		return _lookup_pos(p_key, _pos);
 		return _lookup_pos(p_key, _pos);