2#include "gaia/config/config.h"
6#include "gaia/cnt/darray.h"
7#include "gaia/cnt/map.h"
8#include "gaia/core/hashing_policy.h"
15 using ArchetypeId = uint32_t;
16 using ArchetypeDArray = cnt::darray<Archetype*>;
17 using CArchetypeDArray = cnt::darray<const Archetype*>;
18 using ArchetypeIdHash = core::direct_hash_key<uint32_t>;
20 struct ArchetypeIdHashPair {
24 GAIA_NODISCARD
bool operator==(ArchetypeIdHashPair other)
const {
25 return id == other.id;
27 GAIA_NODISCARD
bool operator!=(ArchetypeIdHashPair other)
const {
28 return id != other.id;
32 static constexpr ArchetypeId ArchetypeIdBad = (ArchetypeId)-1;
33 static constexpr ArchetypeIdHashPair ArchetypeIdHashPairBad = {ArchetypeIdBad, {0}};
35 class ArchetypeIdLookupKey final {
37 using LookupHash = core::direct_hash_key<uint32_t>;
41 ArchetypeIdHash m_hash;
44 GAIA_NODISCARD
static LookupHash calc(ArchetypeId
id) {
45 return {
static_cast<uint32_t
>(core::calculate_hash64(
id))};
48 static constexpr bool IsDirectHashKey =
true;
50 ArchetypeIdLookupKey(): m_id(0), m_hash({0}) {}
51 ArchetypeIdLookupKey(ArchetypeIdHashPair pair): m_id(pair.id), m_hash(pair.hash) {}
52 explicit ArchetypeIdLookupKey(ArchetypeId
id, LookupHash hash): m_id(id), m_hash(hash) {}
54 GAIA_NODISCARD
size_t hash()
const {
55 return (
size_t)m_hash.hash;
58 GAIA_NODISCARD
bool operator==(
const ArchetypeIdLookupKey& other)
const {
61 if GAIA_LIKELY (m_hash != other.m_hash)
64 return m_id == other.m_id;
68 using ArchetypeMapById = cnt::map<ArchetypeIdLookupKey, Archetype*>;