UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
LocKeyFuncs.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreTypes.h"
5#include "Containers/Set.h"
6#include "Containers/Map.h"
7
9class FLocKey
10{
11public:
13 : Str()
14 , Hash(0)
15 {
16 }
17
19 : Str(InStr)
20 , Hash(ProduceHash(Str))
21 {
22 }
23
24 FLocKey(const FString& InStr)
25 : Str(InStr)
26 , Hash(ProduceHash(Str))
27 {
28 }
29
30 FLocKey(FString&& InStr)
31 : Str(MoveTemp(InStr))
32 , Hash(ProduceHash(Str))
33 {
34 }
35
37 : Str(InOther.Str)
38 , Hash(InOther.Hash)
39 {
40 }
41
43 : Str(MoveTemp(InOther.Str))
44 , Hash(InOther.Hash)
45 {
46 InOther.Hash = 0;
47 }
48
50 {
51 if (this != &InOther)
52 {
53 Str = InOther.Str;
54 Hash = InOther.Hash;
55 }
56
57 return *this;
58 }
59
61 {
62 if (this != &InOther)
63 {
64 Str = MoveTemp(InOther.Str);
65 Hash = InOther.Hash;
66
67 InOther.Hash = 0;
68 }
69
70 return *this;
71 }
72
74 {
75 return Hash == Other.Hash && Compare(Other) == 0;
76 }
77
79 {
80 return Hash != Other.Hash || Compare(Other) != 0;
81 }
82
84 {
85 return Compare(Other) < 0;
86 }
87
89 {
90 return Compare(Other) <= 0;
91 }
92
94 {
95 return Compare(Other) > 0;
96 }
97
99 {
100 return Compare(Other) >= 0;
101 }
102
103 friend inline uint32 GetTypeHash(const FLocKey& Id)
104 {
105 return Id.Hash;
106 }
107
109 {
110 return Str.IsEmpty();
111 }
112
114 {
115 return *this == Other;
116 }
117
119 {
120 return FCString::Strcmp(*Str, *Other.Str);
121 }
122
123 UE_FORCEINLINE_HINT const FString& GetString() const
124 {
125 return Str;
126 }
127
129 {
130 return FCrc::StrCrc32<TCHAR>(*InStr, InBaseHash);
131 }
132
133private:
135 FString Str;
136
138 uint32 Hash;
139};
140
142struct FLocKeySetFuncs : BaseKeyFuncs<FString, FString>
143{
144 static UE_FORCEINLINE_HINT const FString& GetSetKey(const FString& Element)
145 {
146 return Element;
147 }
148 static UE_FORCEINLINE_HINT bool Matches(const FString& A, const FString& B)
149 {
150 return A.Equals(B, ESearchCase::CaseSensitive);
151 }
152 static UE_FORCEINLINE_HINT uint32 GetKeyHash(const FString& Key)
153 {
154 return FLocKey::ProduceHash(Key);
155 }
156};
157
159template <typename ValueType>
160struct FLocKeyMapFuncs : BaseKeyFuncs<ValueType, FString, /*bInAllowDuplicateKeys*/false>
161{
162 static UE_FORCEINLINE_HINT const FString& GetSetKey(const TPair<FString, ValueType>& Element)
163 {
164 return Element.Key;
165 }
166 static UE_FORCEINLINE_HINT bool Matches(const FString& A, const FString& B)
167 {
168 return A.Equals(B, ESearchCase::CaseSensitive);
169 }
170 static UE_FORCEINLINE_HINT uint32 GetKeyHash(const FString& Key)
171 {
172 return FLocKey::ProduceHash(Key);
173 }
174};
175
177template <typename ValueType>
178struct FLocKeyMultiMapFuncs : BaseKeyFuncs<ValueType, FString, /*bInAllowDuplicateKeys*/true>
179{
180 static UE_FORCEINLINE_HINT const FString& GetSetKey(const TPair<FString, ValueType>& Element)
181 {
182 return Element.Key;
183 }
184 static UE_FORCEINLINE_HINT bool Matches(const FString& A, const FString& B)
185 {
186 return A.Equals(B, ESearchCase::CaseSensitive);
187 }
188 static UE_FORCEINLINE_HINT uint32 GetKeyHash(const FString& Key)
189 {
190 return FLocKey::ProduceHash(Key);
191 }
192};
193
196{
197 UE_FORCEINLINE_HINT bool operator()(const FString& A, const FString& B) const
198 {
199 return A.Compare(B, ESearchCase::CaseSensitive) < 0;
200 }
201};
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition LocKeyFuncs.h:10
UE_FORCEINLINE_HINT bool Equals(const FLocKey &Other) const
Definition LocKeyFuncs.h:113
UE_FORCEINLINE_HINT bool operator<(const FLocKey &Other) const
Definition LocKeyFuncs.h:83
UE_FORCEINLINE_HINT bool operator!=(const FLocKey &Other) const
Definition LocKeyFuncs.h:78
FLocKey & operator=(const FLocKey &InOther)
Definition LocKeyFuncs.h:49
UE_FORCEINLINE_HINT int32 Compare(const FLocKey &Other) const
Definition LocKeyFuncs.h:118
UE_FORCEINLINE_HINT bool operator==(const FLocKey &Other) const
Definition LocKeyFuncs.h:73
FLocKey(FLocKey &&InOther)
Definition LocKeyFuncs.h:42
friend uint32 GetTypeHash(const FLocKey &Id)
Definition LocKeyFuncs.h:103
UE_FORCEINLINE_HINT const FString & GetString() const
Definition LocKeyFuncs.h:123
FLocKey()
Definition LocKeyFuncs.h:12
FLocKey(const TCHAR *InStr)
Definition LocKeyFuncs.h:18
static UE_FORCEINLINE_HINT uint32 ProduceHash(const FString &InStr, const uint32 InBaseHash=0)
Definition LocKeyFuncs.h:128
UE_FORCEINLINE_HINT bool operator>=(const FLocKey &Other) const
Definition LocKeyFuncs.h:98
FLocKey(FString &&InStr)
Definition LocKeyFuncs.h:30
FLocKey(const FLocKey &InOther)
Definition LocKeyFuncs.h:36
FLocKey & operator=(FLocKey &&InOther)
Definition LocKeyFuncs.h:60
FLocKey(const FString &InStr)
Definition LocKeyFuncs.h:24
UE_FORCEINLINE_HINT bool IsEmpty() const
Definition LocKeyFuncs.h:108
UE_FORCEINLINE_HINT bool operator>(const FLocKey &Other) const
Definition LocKeyFuncs.h:93
UE_FORCEINLINE_HINT bool operator<=(const FLocKey &Other) const
Definition LocKeyFuncs.h:88
@ CaseSensitive
Definition CString.h:23
Definition SetUtilities.h:23
Definition LocKeyFuncs.h:161
static UE_FORCEINLINE_HINT bool Matches(const FString &A, const FString &B)
Definition LocKeyFuncs.h:166
static UE_FORCEINLINE_HINT const FString & GetSetKey(const TPair< FString, ValueType > &Element)
Definition LocKeyFuncs.h:162
static UE_FORCEINLINE_HINT uint32 GetKeyHash(const FString &Key)
Definition LocKeyFuncs.h:170
Definition LocKeyFuncs.h:179
static UE_FORCEINLINE_HINT const FString & GetSetKey(const TPair< FString, ValueType > &Element)
Definition LocKeyFuncs.h:180
static UE_FORCEINLINE_HINT uint32 GetKeyHash(const FString &Key)
Definition LocKeyFuncs.h:188
static UE_FORCEINLINE_HINT bool Matches(const FString &A, const FString &B)
Definition LocKeyFuncs.h:184
Definition LocKeyFuncs.h:143
static UE_FORCEINLINE_HINT bool Matches(const FString &A, const FString &B)
Definition LocKeyFuncs.h:148
static UE_FORCEINLINE_HINT const FString & GetSetKey(const FString &Element)
Definition LocKeyFuncs.h:144
static UE_FORCEINLINE_HINT uint32 GetKeyHash(const FString &Key)
Definition LocKeyFuncs.h:152
Definition LocKeyFuncs.h:196
UE_FORCEINLINE_HINT bool operator()(const FString &A, const FString &B) const
Definition LocKeyFuncs.h:197
static UE_FORCEINLINE_HINT int32 Strcmp(const CharType *String1, const CharType *String2)
Definition CString.h:1018
Definition Tuple.h:652