UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
HashTraits.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6
7namespace uLang
8{
9// Default hash function for pointers.
10inline uint32_t GetTypeHash(const void* Key)
11{
12 const uintptr_t PtrInt = reinterpret_cast<uintptr_t>(Key) >> 4;
13 uint32_t Hash = static_cast<uint32_t>(PtrInt);
14 Hash ^= Hash >> 16;
15 Hash *= 0x85ebca6b;
16 Hash ^= Hash >> 13;
17 Hash *= 0xc2b2ae35;
18 Hash ^= Hash >> 16;
19 return Hash;
20}
21
23{
24 Hash ^= Hash >> 16;
25 Hash *= 0x85ebca6b;
26 Hash ^= Hash >> 13;
27 Hash *= 0xc2b2ae35;
28 Hash ^= Hash >> 16;
29 return Hash;
30}
31
41{
42 return A ^ (B + 0x9e3779b9 + (A << 6) + (A >> 2));
43}
44
46{
47 return MurmurFinalize32(I);
48}
49
51{
52 return MurmurFinalize32(static_cast<uint32_t>(I));
53}
54
56{
57 return HashCombineFast(MurmurFinalize32(static_cast<uint32_t>(I)), MurmurFinalize32(static_cast<uint32_t>(I >> 32)));
58}
59
61{
62 return HashCombineFast(MurmurFinalize32(static_cast<uint32_t>(I)), MurmurFinalize32(static_cast<uint32_t>(static_cast<uint64_t>(I) >> 32)));
63}
64
65template<class KeyType>
67{
68 static uint32_t GetKeyHash(const KeyType& Key) { return GetTypeHash(Key); }
69};
70}
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition VVMEngineEnvironment.h:23
uint32_t MurmurFinalize32(uint32_t Hash)
Definition HashTraits.h:22
constexpr uint32_t HashCombineFast(uint32_t A, uint32_t B)
Definition HashTraits.h:40
ULANG_FORCEINLINE uint32_t GetTypeHash(const TArray< T > Array)
Definition Array.h:2132
Definition HashTraits.h:67
static uint32_t GetKeyHash(const KeyType &Key)
Definition HashTraits.h:68