UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Map.h.inl
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#ifndef UE_TMAP_PREFIX
4#error "Map.h.inl should only be included after defining UE_TMAP_PREFIX"
5#endif
6
7#define TMAPBASE PREPROCESSOR_JOIN(UE_TMAP_PREFIX, MapBase)
8#define TSORTABLEMAPBASE PREPROCESSOR_JOIN(UE_TMAP_PREFIX, SortableMapBase)
9#define TMAP PREPROCESSOR_JOIN(UE_TMAP_PREFIX, Map)
10#define TMAPPRIVATEFRIEND PREPROCESSOR_JOIN(TMAP,PrivateFriend)
11#define TMULTIMAP PREPROCESSOR_JOIN(UE_TMAP_PREFIX, MultiMap)
12#define TSET PREPROCESSOR_JOIN(UE_TMAP_PREFIX, Set)
13#define TMAP_STRINGIFY(name) #name
14
27template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
29{
30 template <typename OtherKeyType, typename OtherValueType, typename OtherSetAllocator, typename OtherKeyFuncs>
31 friend class TMAPBASE;
32
33public:
38
39protected:
40 [[nodiscard]] constexpr TMAPBASE() = default;
41 [[nodiscard]] explicit consteval TMAPBASE(EConstEval)
43 {
44 }
45 [[nodiscard]] TMAPBASE(TMAPBASE&&) = default;
46 [[nodiscard]] TMAPBASE(const TMAPBASE&) = default;
48 TMAPBASE& operator=(const TMAPBASE&) = default;
49
51 template<typename OtherSetAllocator>
56
58 template<typename OtherSetAllocator>
63
65 {
66 UE_STATIC_ASSERT_WARN(TIsTriviallyRelocatable_V<KeyType> && TIsTriviallyRelocatable_V<ValueType>, "TMapBase can only be used with trivially relocatable types");
67 }
68
70 // Start - intrusive TOptional<TMAPBASE> state //
72 constexpr static bool bHasIntrusiveUnsetOptionalState = true;
74
80 {
81 return Pairs == Tag;
82 }
84 // End - intrusive TOptional<TMAPBASE> state //
86
88 template<typename OtherSetAllocator>
94
96 template<typename OtherSetAllocator>
102
103public:
104
114 {
115 // first check counts (they should be the same obviously)
116 if (Num() != Other.Num())
117 {
118 return false;
119 }
120
121 // since we know the counts are the same, we can just iterate one map and check for existence in the other
122 for (typename ElementSetType::TConstIterator It(Pairs); It; ++It)
123 {
124 const ValueType* BVal = Other.Find(It->Key);
125 if (BVal == nullptr)
126 {
127 return false;
128 }
129 if (!(*BVal == It->Value))
130 {
131 return false;
132 }
133 }
134
135 // all fields in A match B and A and B's counts are the same (so there can be no fields in B not in A)
136 return true;
137 }
138
151
154 {
155 Pairs.Reset();
156 }
157
160 {
161 Pairs.Shrink();
162 }
163
166 {
167 Pairs.Compact();
168 }
169
172 {
173 Pairs.CompactStable();
174 }
175
178 {
179 Pairs.Reserve(Number);
180 }
181
188 [[nodiscard]] bool IsEmpty() const
189 {
190 return Pairs.IsEmpty();
191 }
192
195 {
196 return Pairs.Num();
197 }
198
201 {
202 return Pairs.Max();
203 }
204
207 {
208 return Pairs.GetMaxIndex();
209 }
210
217 {
218 return Pairs.IsValidId(Id);
219 }
220
226
229 {
230 return Pairs[Id];
231 }
232
239 template<typename Allocator> int32 GetKeys(TArray<KeyType, Allocator>& OutKeys) const
240 {
241 OutKeys.Reset();
242
244 VisitedKeys.Reserve(Num());
245
246 // Presize the array if we know there are supposed to be no duplicate keys
247 if constexpr (!KeyFuncs::bAllowDuplicateKeys)
248 {
249 OutKeys.Reserve(Num());
250 }
251
252 for (typename ElementSetType::TConstIterator It(Pairs); It; ++It)
253 {
254 // Even if bAllowDuplicateKeys is false, we still want to filter for duplicate
255 // keys due to maps with keys that can be invalidated (UObjects, TWeakObj, etc.)
256 if (!VisitedKeys.Contains(It->Key))
257 {
258 OutKeys.Add(It->Key);
259 VisitedKeys.Add(It->Key);
260 }
261 }
262
263 return OutKeys.Num();
264 }
265
272 template<typename InSetKeyFuncs, typename InSetAllocator> int32 GetKeys(TSet<KeyType, InSetKeyFuncs, InSetAllocator>& OutKeys) const
273 {
274 OutKeys.Reset();
275
276 // Presize the set if we know there are supposed to be no duplicate keys
277 if (!KeyFuncs::bAllowDuplicateKeys)
278 {
279 OutKeys.Reserve(Num());
280 }
281
282 for (typename ElementSetType::TConstIterator It(Pairs); It; ++It)
283 {
284 OutKeys.Add(It->Key);
285 }
286
287 return OutKeys.Num();
288 }
289
298 {
299 return Pairs.GetAllocatedSize();
300 }
301
309 {
310 Pairs.CountBytes(Ar);
311 }
312
320 UE_FORCEINLINE_HINT ValueType& Add(const KeyType& InKey, const ValueType& InValue) { return Emplace(InKey, InValue); }
321 UE_FORCEINLINE_HINT ValueType& Add(const KeyType& InKey, ValueType&& InValue) { return Emplace(InKey, MoveTempIfPossible(InValue)); }
322 UE_FORCEINLINE_HINT ValueType& Add( KeyType&& InKey, const ValueType& InValue) { return Emplace(MoveTempIfPossible(InKey), InValue); }
324
326 UE_FORCEINLINE_HINT ValueType& AddByHash(uint32 KeyHash, const KeyType& InKey, const ValueType& InValue) { return EmplaceByHash(KeyHash, InKey, InValue); }
327 UE_FORCEINLINE_HINT ValueType& AddByHash(uint32 KeyHash, const KeyType& InKey, ValueType&& InValue) { return EmplaceByHash(KeyHash, InKey, MoveTempIfPossible(InValue)); }
328 UE_FORCEINLINE_HINT ValueType& AddByHash(uint32 KeyHash, KeyType&& InKey, const ValueType& InValue) { return EmplaceByHash(KeyHash, MoveTempIfPossible(InKey), InValue); }
329 UE_FORCEINLINE_HINT ValueType& AddByHash(uint32 KeyHash, KeyType&& InKey, ValueType&& InValue) { return EmplaceByHash(KeyHash, MoveTempIfPossible(InKey), MoveTempIfPossible(InValue)); }
330
337 UE_FORCEINLINE_HINT ValueType& Add(const KeyType& InKey) { return Emplace(InKey); }
338 UE_FORCEINLINE_HINT ValueType& Add( KeyType&& InKey) { return Emplace(MoveTempIfPossible(InKey)); }
339
341 UE_FORCEINLINE_HINT ValueType& AddByHash(uint32 KeyHash, const KeyType& InKey) { return EmplaceByHash(KeyHash, InKey); }
342 UE_FORCEINLINE_HINT ValueType& AddByHash(uint32 KeyHash, KeyType&& InKey) { return EmplaceByHash(KeyHash, MoveTempIfPossible(InKey)); }
343
352
360 template <typename InitKeyType = KeyType, typename InitValueType = ValueType>
367
369 template <typename InitKeyType = KeyType, typename InitValueType = ValueType>
376
383 template <typename InitKeyType = KeyType>
385 {
387
388 return Pairs[PairId].Value;
389 }
390
392 template <typename InitKeyType = KeyType>
393 ValueType& EmplaceByHash(uint32 KeyHash, InitKeyType&& InKey)
394 {
396
397 return Pairs[PairId].Value;
398 }
399
407 {
408 const int32 NumRemovedPairs = Pairs.Remove(InKey);
409 return NumRemovedPairs;
410 }
411
413 {
414 const int32 NumRemovedPairs = Pairs.RemoveStable(InKey);
415 return NumRemovedPairs;
416 }
417
419 template<typename ComparableKey>
420 inline int32 RemoveByHash(uint32 KeyHash, const ComparableKey& Key)
421 {
422 const int32 NumRemovedPairs = Pairs.RemoveByHash(KeyHash, Key);
423 return NumRemovedPairs;
424 }
425
431 {
432 Pairs.Remove(Id);
433 }
434
445 [[nodiscard]] const KeyType* FindKey(ValueInitType Value) const
446 {
447 for (typename ElementSetType::TConstIterator PairIt(Pairs); PairIt; ++PairIt)
448 {
449 if (PairIt->Value == Value)
450 {
451 return &PairIt->Key;
452 }
453 }
454 return nullptr;
455 }
456
464 template <typename Predicate>
466 {
469 for (const ElementType& Pair : Pairs)
470 {
471 if (Pred(Pair))
472 {
473 FilterResults.Add(Pair);
474 }
475 }
476 return FilterResults;
477 }
478
486 [[nodiscard]] inline ValueType* Find(KeyConstPointerType Key)
487 {
488 if (auto* Pair = Pairs.Find(Key))
489 {
490 return &Pair->Value;
491 }
492
493 return nullptr;
494 }
496 {
497 return const_cast<TMAPBASE*>(this)->Find(Key);
498 }
499
501 template<typename ComparableKey>
502 [[nodiscard]] inline ValueType* FindByHash(uint32 KeyHash, const ComparableKey& Key)
503 {
504 if (auto* Pair = Pairs.FindByHash(KeyHash, Key))
505 {
506 return &Pair->Value;
507 }
508
509 return nullptr;
510 }
511 template<typename ComparableKey>
512 [[nodiscard]] UE_FORCEINLINE_HINT const ValueType* FindByHash(uint32 KeyHash, const ComparableKey& Key) const
513 {
514 return const_cast<TMAPBASE*>(this)->FindByHash(KeyHash, Key);
515 }
516
517 template<typename ComparableKey>
518 [[nodiscard]] inline ValueType& FindByHashChecked(uint32 KeyHash, const ComparableKey& Key)
519 {
520 auto* Pair = Pairs.FindByHash(KeyHash, Key);
521 check(Pair != nullptr);
522 return Pair->Value;
523 }
524 template<typename ComparableKey>
525 [[nodiscard]] UE_FORCEINLINE_HINT const ValueType& FindByHashChecked(uint32 KeyHash, const ComparableKey& Key) const
526 {
527 return const_cast<TMAPBASE*>(this)->FindByHashChecked(KeyHash, Key);
528 }
529
537 {
538 return Pairs.FindId(Key);
539 }
540
542 template<typename ComparableKey>
544 {
545 return Pairs.FindIdByHash(KeyHash, Key);
546 }
547
548private:
549 [[nodiscard]] UE_FORCEINLINE_HINT static uint32 HashKey(const KeyType& Key)
550 {
551 return KeyFuncs::GetKeyHash(Key);
552 }
553
561 template <typename InitKeyType>
562 [[nodiscard]] ValueType& FindOrAddImpl(uint32 KeyHash, InitKeyType&& Key)
563 {
564 if (auto* Pair = Pairs.FindByHash(KeyHash, Key))
565 {
566 return Pair->Value;
567 }
568
569 return AddByHash(KeyHash, Forward<InitKeyType>(Key));
570 }
571
580 template <typename InitKeyType, typename InitValueType>
581 [[nodiscard]] ValueType& FindOrAddImpl(uint32 KeyHash, InitKeyType&& Key, InitValueType&& Value)
582 {
583 if (auto* Pair = Pairs.FindByHash(KeyHash, Key))
584 {
585 return Pair->Value;
586 }
587
589 }
590
591public:
592
600 UE_FORCEINLINE_HINT ValueType& FindOrAdd(const KeyType& Key) { return FindOrAddImpl(HashKey(Key), Key); }
601 UE_FORCEINLINE_HINT ValueType& FindOrAdd( KeyType&& Key) { return FindOrAddImpl(HashKey(Key), MoveTempIfPossible(Key)); }
602
604 UE_FORCEINLINE_HINT ValueType& FindOrAddByHash(uint32 KeyHash, const KeyType& Key) { return FindOrAddImpl(KeyHash, Key); }
605 UE_FORCEINLINE_HINT ValueType& FindOrAddByHash(uint32 KeyHash, KeyType&& Key) { return FindOrAddImpl(KeyHash, MoveTempIfPossible(Key)); }
606
615 UE_FORCEINLINE_HINT ValueType& FindOrAdd(const KeyType& Key, const ValueType& Value) { return FindOrAddImpl(HashKey(Key), Key, Value ); }
616 UE_FORCEINLINE_HINT ValueType& FindOrAdd(const KeyType& Key, ValueType&& Value) { return FindOrAddImpl(HashKey(Key), Key, MoveTempIfPossible(Value) ); }
617 UE_FORCEINLINE_HINT ValueType& FindOrAdd( KeyType&& Key, const ValueType& Value) { return FindOrAddImpl(HashKey(Key), MoveTempIfPossible(Key), Value ); }
618 UE_FORCEINLINE_HINT ValueType& FindOrAdd( KeyType&& Key, ValueType&& Value) { return FindOrAddImpl(HashKey(Key), MoveTempIfPossible(Key), MoveTempIfPossible(Value) ); }
619
621 UE_FORCEINLINE_HINT ValueType& FindOrAddByHash(uint32 KeyHash, const KeyType& Key, const ValueType& Value) { return FindOrAddImpl(KeyHash, Key, Value); }
622 UE_FORCEINLINE_HINT ValueType& FindOrAddByHash(uint32 KeyHash, const KeyType& Key, ValueType&& Value) { return FindOrAddImpl(KeyHash, Key, MoveTempIfPossible(Value)); }
623 UE_FORCEINLINE_HINT ValueType& FindOrAddByHash(uint32 KeyHash, KeyType&& Key, const ValueType& Value) { return FindOrAddImpl(KeyHash, MoveTempIfPossible(Key), Value); }
624 UE_FORCEINLINE_HINT ValueType& FindOrAddByHash(uint32 KeyHash, KeyType&& Key, ValueType&& Value) { return FindOrAddImpl(KeyHash, MoveTempIfPossible(Key), MoveTempIfPossible(Value)); }
625
632 [[nodiscard]] inline const ValueType& FindChecked(KeyConstPointerType Key) const
633 {
634 const auto* Pair = Pairs.Find(Key);
635 check(Pair != nullptr);
636 return Pair->Value;
637 }
638
645 [[nodiscard]] inline ValueType& FindChecked(KeyConstPointerType Key)
646 {
647 auto* Pair = Pairs.Find(Key);
648 check(Pair != nullptr);
649 return Pair->Value;
650 }
651
658 [[nodiscard]] inline ValueType FindRef(KeyConstPointerType Key) const
659 {
660 if (const auto* Pair = Pairs.Find(Key))
661 {
662 return Pair->Value;
663 }
664
665 return ValueType();
666 }
667
675 [[nodiscard]] inline ValueType FindRef(KeyConstPointerType Key, ValueType DefaultValue) const
676 {
677 if (const auto* Pair = Pairs.Find(Key))
678 {
679 return Pair->Value;
680 }
681
682 return DefaultValue;
683 }
684
691 {
692 // The goal of this function is to be fast, and so the implementation may be improved at any time even if it gives different results.
693
694 return Pairs.FindArbitraryElement();
695 }
697 {
698 return const_cast<TMAPBASE*>(this)->FindArbitraryElement();
699 }
700
708 {
709 return Pairs.Contains(Key);
710 }
711
713 template<typename ComparableKey>
715 {
716 return Pairs.ContainsByHash(KeyHash, Key);
717 }
718
721 {
722 return Pairs.Array();
723 }
724
730 template<typename Allocator> void GenerateKeyArray(TArray<KeyType, Allocator>& OutArray) const
731 {
732 OutArray.Empty(Pairs.Num());
733 for (typename ElementSetType::TConstIterator PairIt(Pairs); PairIt; ++PairIt)
734 {
735 OutArray.Add(PairIt->Key);
736 }
737 }
738
744 template<typename Allocator> void GenerateValueArray(TArray<ValueType, Allocator>& OutArray) const
745 {
746 OutArray.Empty(Pairs.Num());
747 for (typename ElementSetType::TConstIterator PairIt(Pairs); PairIt; ++PairIt)
748 {
749 OutArray.Add(PairIt->Value);
750 }
751 }
752
759 {
760 Pairs.Dump(Ar);
761 }
762
763protected:
765
767 template<bool bConst>
769 {
770 public:
771 typedef std::conditional_t<
772 bConst,
773 typename ElementSetType::TConstIterator,
774 typename ElementSetType::TIterator
776 private:
777 typedef std::conditional_t<bConst, const KeyType, KeyType> ItKeyType;
778 typedef std::conditional_t<bConst, const ValueType, ValueType> ItValueType;
779 typedef std::conditional_t<bConst, const typename ElementSetType::ElementType, typename ElementSetType::ElementType> PairType;
780
781 public:
786
788 {
789 ++PairIt;
790 return *this;
791 }
792
794 [[nodiscard]] UE_FORCEINLINE_HINT explicit operator bool() const
795 {
796 return !!PairIt;
797 }
800 {
801 return !(bool)*this;
802 }
803
805 {
806 return PairIt == Rhs.PairIt;
807 }
809 {
810 return PairIt != Rhs.PairIt;
811 }
812
813 [[nodiscard]] UE_FORCEINLINE_HINT ItKeyType& Key() const
814 {
815 return PairIt->Key;
816 }
817 [[nodiscard]] UE_FORCEINLINE_HINT ItValueType& Value() const
818 {
819 return PairIt->Value;
820 }
821
823 {
824 return PairIt.GetId();
825 }
826
828 {
829 return *PairIt;
830 }
832 {
833 return &*PairIt;
834 }
835
836 protected:
838 };
839
841 template<bool bConst>
843 {
844 private:
845 typedef std::conditional_t<bConst, typename ElementSetType::TConstKeyIterator, typename ElementSetType::TKeyIterator> SetItType;
846 typedef std::conditional_t<bConst, const KeyType, KeyType> ItKeyType;
847 typedef std::conditional_t<bConst, const ValueType, ValueType> ItValueType;
848
849 public:
852 : SetIt(InSetIt)
853 {
854 }
855
857 {
858 ++SetIt;
859 return *this;
860 }
861
863 [[nodiscard]] UE_FORCEINLINE_HINT explicit operator bool() const
864 {
865 return !!SetIt;
866 }
869 {
870 return !(bool)*this;
871 }
872
874 {
875 return SetIt.GetId();
876 }
877 [[nodiscard]] UE_FORCEINLINE_HINT ItKeyType& Key() const
878 {
879 return SetIt->Key;
880 }
881 [[nodiscard]] UE_FORCEINLINE_HINT ItValueType& Value() const
882 {
883 return SetIt->Value;
884 }
885
886 [[nodiscard]] UE_FORCEINLINE_HINT decltype(auto) operator*() const
887 {
888 return SetIt.operator*();
889 }
890 [[nodiscard]] UE_FORCEINLINE_HINT decltype(auto) operator->() const
891 {
892 return SetIt.operator->();
893 }
894
895 protected:
896 SetItType SetIt;
897 };
898
901
902public:
904 {
905 Pairs.WriteMemoryImage(Writer);
906 }
907
908 void CopyUnfrozen(const FMemoryUnfreezeContent& Context, void* Dst) const
909 {
910 Pairs.CopyUnfrozen(Context, Dst);
911 }
912
913 static void AppendHash(const FPlatformTypeLayoutParameters& LayoutParams, FSHA1& Hasher)
914 {
915 ElementSetType::AppendHash(LayoutParams, Hasher);
916 }
917
919 class TIterator : public TBaseIterator<false>
920 {
921 public:
922
925 : TBaseIterator<false>(InMap.Pairs.CreateIterator())
926 , Map(InMap)
927 , bElementsHaveBeenRemoved(false)
928 , bRequiresRehashOnRemoval(bInRequiresRehashOnRemoval)
929 {
930 }
931
933 inline ~TIterator()
934 {
935 if (bElementsHaveBeenRemoved && bRequiresRehashOnRemoval)
936 {
937 Map.Pairs.Relax();
938 }
939 }
940
945 inline void RemoveCurrent()
946 {
947 TBaseIterator<false>::PairIt.RemoveCurrent();
948 bElementsHaveBeenRemoved = true;
949 }
950
951 private:
952 TMAPBASE& Map;
953 bool bElementsHaveBeenRemoved;
954 bool bRequiresRehashOnRemoval;
955 };
956
958 class TConstIterator : public TBaseIterator<true>
959 {
960 public:
962 : TBaseIterator<true>(InMap.Pairs.CreateConstIterator())
963 {
964 }
965 };
966
967 using TRangedForIterator = typename ElementSetType::TRangedForIterator;
968 using TRangedForConstIterator = typename ElementSetType::TRangedForConstIterator;
969
972 {
973 private:
975 using IteratorType = typename ElementSetType::TConstKeyIterator;
976
977 public:
978 using KeyArgumentType = typename IteratorType::KeyArgumentType;
979
984 };
985
987 class TKeyIterator : public TBaseKeyIterator<false>
988 {
989 private:
991 using IteratorType = typename ElementSetType::TKeyIterator;
992
993 public:
994 using KeyArgumentType = typename IteratorType::KeyArgumentType;
995
1000
1003 {
1004 TBaseKeyIterator<false>::SetIt.RemoveCurrent();
1005 }
1006 };
1007
1010 {
1011 return TIterator(*this);
1012 }
1013
1019
1025
1031
1032 friend struct TMAPPRIVATEFRIEND;
1033
1034public:
1043
1044 // Maps are deliberately prevented from being hashed or compared, because this would hide potentially major performance problems behind default operations.
1045 friend uint32 GetTypeHash(const TMAPBASE& Map) = delete;
1046 friend bool operator==(const TMAPBASE&, const TMAPBASE&) = delete;
1047 friend bool operator!=(const TMAPBASE&, const TMAPBASE&) = delete;
1048};
1049
1051template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
1052class TSORTABLEMAPBASE : public TMAPBASE<KeyType, ValueType, SetAllocator, KeyFuncs>
1053{
1054protected:
1056
1057 [[nodiscard]] constexpr TSORTABLEMAPBASE() = default;
1058 [[nodiscard]] explicit consteval TSORTABLEMAPBASE(EConstEval)
1059 : Super(ConstEval)
1060 {
1061 }
1066
1068 template<typename OtherSetAllocator>
1073
1075 template<typename OtherSetAllocator>
1080
1082 template<typename OtherSetAllocator>
1088
1090 template<typename OtherSetAllocator>
1096
1098 // Start - intrusive TOptional<TSORTABLEMAPBASE> state //
1100 constexpr static bool bHasIntrusiveUnsetOptionalState = true;
1102
1108 {
1109 return Super::operator==(Tag);
1110 }
1112 // End - intrusive TOptional<TSORTABLEMAPBASE> state //
1114
1115public:
1120 template<typename PREDICATE_CLASS>
1122 {
1123 Super::Pairs.Sort(FKeyComparisonClass<PREDICATE_CLASS>(Predicate));
1124 }
1125
1130 template<typename PREDICATE_CLASS>
1132 {
1133 Super::Pairs.StableSort(FKeyComparisonClass<PREDICATE_CLASS>(Predicate));
1134 }
1135
1140 template<typename PREDICATE_CLASS>
1142 {
1143 Super::Pairs.Sort(FValueComparisonClass<PREDICATE_CLASS>(Predicate));
1144 }
1145
1150 template<typename PREDICATE_CLASS>
1152 {
1153 Super::Pairs.StableSort(FValueComparisonClass<PREDICATE_CLASS>(Predicate));
1154 }
1155
1162 {
1163 Super::Pairs.SortFreeList();
1164 }
1165
1166private:
1167
1169 template<typename PREDICATE_CLASS>
1170 class FKeyComparisonClass
1171 {
1173
1174 public:
1175
1176 [[nodiscard]] UE_FORCEINLINE_HINT FKeyComparisonClass(const PREDICATE_CLASS& InPredicate)
1177 : Predicate(InPredicate)
1178 {
1179 }
1180
1181 [[nodiscard]] inline bool operator()(const typename Super::ElementType& A, const typename Super::ElementType& B) const
1182 {
1183 return Predicate(A.Key, B.Key);
1184 }
1185 };
1186
1188 template<typename PREDICATE_CLASS>
1189 class FValueComparisonClass
1190 {
1192
1193 public:
1194
1195 [[nodiscard]] UE_FORCEINLINE_HINT FValueComparisonClass(const PREDICATE_CLASS& InPredicate)
1196 : Predicate(InPredicate)
1197 {
1198 }
1199
1200 [[nodiscard]] inline bool operator()(const typename Super::ElementType& A, const typename Super::ElementType& B) const
1201 {
1202 return Predicate(A.Value, B.Value);
1203 }
1204 };
1205};
1206
1208template<typename InKeyType, typename InValueType, typename SetAllocator /*= FDefaultSetAllocator*/, typename KeyFuncs /*= TDefaultMapHashableKeyFuncs<KeyType,ValueType,false>*/>
1209class TMAP : public TSORTABLEMAPBASE<InKeyType, InValueType, SetAllocator, KeyFuncs>
1210{
1211 template <typename, typename>
1212 friend class TScriptMap;
1213
1214 static_assert(!KeyFuncs::bAllowDuplicateKeys, TMAP_STRINGIFY(TMAP) " cannot be instantiated with a KeyFuncs which allows duplicate keys");
1215
1216public:
1219 typedef SetAllocator SetAllocatorType;
1220 typedef KeyFuncs KeyFuncsType;
1221
1225
1226 [[nodiscard]] constexpr TMAP() = default;
1227 [[nodiscard]] explicit consteval TMAP(EConstEval)
1228 : Super(ConstEval)
1229 {
1230 }
1231 [[nodiscard]] TMAP(TMAP&&) = default;
1232 [[nodiscard]] TMAP(const TMAP&) = default;
1233 TMAP& operator=(TMAP&&) = default;
1234 TMAP& operator=(const TMAP&) = default;
1235
1237 template<typename OtherSetAllocator>
1242
1244 template<typename OtherSetAllocator>
1249
1252 {
1253 this->Reserve((int32)InitList.size());
1255 {
1256 this->Add(Element.Key, Element.Value);
1257 }
1258 }
1259
1261 // Start - intrusive TOptional<TMAP> state //
1263 constexpr static bool bHasIntrusiveUnsetOptionalState = true;
1265
1267 : Super(Tag)
1268 {
1269 }
1271 {
1272 return Super::operator==(Tag);
1273 }
1275 // End - intrusive TOptional<TMAP> state //
1277
1279 template<typename OtherSetAllocator>
1285
1287 template<typename OtherSetAllocator>
1289 {
1290 (Super&)*this = Other;
1291 return *this;
1292 }
1293
1296 {
1297 this->Empty((int32)InitList.size());
1299 {
1300 this->Add(Element.Key, Element.Value);
1301 }
1302 return *this;
1303 }
1304
1314 {
1315 const FSetElementId PairId = Super::Pairs.FindId(Key);
1316 if (!PairId.IsValidId())
1317 {
1318 return false;
1319 }
1320
1322 Super::Pairs.Remove(PairId);
1323 return true;
1324 }
1325
1328 {
1329 const FSetElementId PairId = Super::Pairs.FindId(Key);
1330 if (!PairId.IsValidId())
1331 {
1332 return false;
1333 }
1334
1336 Super::Pairs.RemoveStable(PairId);
1337 return true;
1338 }
1339
1341 template<typename ComparableKey>
1343 {
1344 const FSetElementId PairId = Super::Pairs.FindIdByHash(KeyHash, Key);
1345 if (!PairId.IsValidId())
1346 {
1347 return false;
1348 }
1349
1351 Super::Pairs.Remove(PairId);
1352 return true;
1353 }
1354
1364 {
1365 const FSetElementId PairId = Super::Pairs.FindId(Key);
1366 check(PairId.IsValidId());
1367 ValueType Result = MoveTempIfPossible(Super::Pairs[PairId].Value);
1368 Super::Pairs.Remove(PairId);
1369 return Result;
1370 }
1371
1378 template<typename OtherSetAllocator>
1380 {
1381 this->Reserve(this->Num() + OtherMap.Num());
1382 for (auto& Pair : OtherMap)
1383 {
1384 this->Add(MoveTempIfPossible(Pair.Key), MoveTempIfPossible(Pair.Value));
1385 }
1386
1387 OtherMap.Reset();
1388 }
1389
1396 template<typename OtherSetAllocator>
1398 {
1399 this->Reserve(this->Num() + OtherMap.Num());
1400 for (auto& Pair : OtherMap)
1401 {
1402 this->Add(Pair.Key, Pair.Value);
1403 }
1404 }
1405
1407 {
1408 return this->FindChecked(Key);
1409 }
1411 {
1412 return this->FindChecked(Key);
1413 }
1414};
1415
1416namespace Freeze
1417{
1418 template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
1420 {
1421 Object.WriteMemoryImage(Writer);
1422 }
1423
1424 template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
1430
1431 template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
1433 {
1435 return DefaultAppendHash(TypeDesc, LayoutParams, Hasher);
1436 }
1437}
1438
1440
1442template<typename KeyType, typename ValueType, typename SetAllocator /* = FDefaultSetAllocator */, typename KeyFuncs /*= TDefaultMapHashableKeyFuncs<KeyType,ValueType,true>*/ /*= FDefaultSetAllocator*/>
1443class TMULTIMAP : public TSORTABLEMAPBASE<KeyType, ValueType, SetAllocator, KeyFuncs>
1444{
1445 static_assert(KeyFuncs::bAllowDuplicateKeys, TMAP_STRINGIFY(TMULTIMAP) " cannot be instantiated with a KeyFuncs which disallows duplicate keys");
1446
1447public:
1452
1453 [[nodiscard]] constexpr TMULTIMAP() = default;
1455 [[nodiscard]] TMULTIMAP(const TMULTIMAP&) = default;
1457 TMULTIMAP& operator=(const TMULTIMAP&) = default;
1458
1460 template<typename OtherSetAllocator>
1465
1467 template<typename OtherSetAllocator>
1472
1475 {
1476 this->Reserve((int32)InitList.size());
1478 {
1479 this->Add(Element.Key, Element.Value);
1480 }
1481 }
1482
1484 // Start - intrusive TOptional<TMULTIMAP> state //
1486 constexpr static bool bHasIntrusiveUnsetOptionalState = true;
1488
1490 : Super(Tag)
1491 {
1492 }
1494 {
1495 return Super::operator==(Tag);
1496 }
1498 // End - intrusive TOptional<TMULTIMAP> state //
1500
1502 template<typename OtherSetAllocator>
1508
1510 template<typename OtherSetAllocator>
1512 {
1513 (Super&)*this = Other;
1514 return *this;
1515 }
1516
1519 {
1520 this->Empty((int32)InitList.size());
1522 {
1523 this->Add(Element.Key, Element.Value);
1524 }
1525 return *this;
1526 }
1527
1535 template<typename Allocator> void MultiFind(KeyInitType Key, TArray<ValueType, Allocator>& OutValues, bool bMaintainOrder = false) const
1536 {
1537 for (typename Super::ElementSetType::TConstKeyIterator It(Super::Pairs, Key); It; ++It)
1538 {
1539 OutValues.Add(It->Value);
1540 }
1541
1542 if (bMaintainOrder)
1543 {
1545 }
1546 }
1547
1556 template<typename Allocator> void MultiFindPointer(KeyInitType Key, TArray<const ValueType*, Allocator>& OutValues, bool bMaintainOrder = false) const
1557 {
1558 for (typename Super::ElementSetType::TConstKeyIterator It(Super::Pairs, Key); It; ++It)
1559 {
1560 OutValues.Add(&It->Value);
1561 }
1562
1563 if (bMaintainOrder)
1564 {
1566 }
1567 }
1568 template<typename Allocator> void MultiFindPointer(KeyInitType Key, TArray<ValueType*, Allocator>& OutValues, bool bMaintainOrder = false)
1569 {
1570 for (typename Super::ElementSetType::TKeyIterator It(Super::Pairs, Key); It; ++It)
1571 {
1572 OutValues.Add(&It->Value);
1573 }
1574
1575 if (bMaintainOrder)
1576 {
1578 }
1579 }
1580
1590 UE_FORCEINLINE_HINT ValueType& AddUnique(const KeyType& InKey, const ValueType& InValue) { return EmplaceUnique(InKey, InValue); }
1591 UE_FORCEINLINE_HINT ValueType& AddUnique(const KeyType& InKey, ValueType&& InValue) { return EmplaceUnique(InKey, MoveTempIfPossible(InValue)); }
1592 UE_FORCEINLINE_HINT ValueType& AddUnique(KeyType&& InKey, const ValueType& InValue) { return EmplaceUnique(MoveTempIfPossible(InKey), InValue); }
1594
1606 template <typename InitKeyType, typename InitValueType>
1608 {
1609 if (ValueType* Found = FindPair(InKey, InValue))
1610 {
1611 return *Found;
1612 }
1613
1614 // If there's no existing association with the same key and value, create one.
1616 }
1617
1625 {
1626 return Super::Remove(InKey);
1627 }
1628
1637 {
1638 // Iterate over pairs with a matching key.
1640 for (typename Super::ElementSetType::TKeyIterator It(Super::Pairs, InKey); It; ++It)
1641 {
1642 // If this pair has a matching value as well, remove it.
1643 if (It->Value == InValue)
1644 {
1645 It.RemoveCurrent();
1647 }
1648 }
1649 return NumRemovedPairs;
1650 }
1651
1660 {
1661 // Iterate over pairs with a matching key.
1663 for (typename Super::ElementSetType::TKeyIterator It(Super::Pairs, InKey); It; ++It)
1664 {
1665 // If this pair has a matching value as well, remove it.
1666 if (It->Value == InValue)
1667 {
1668 It.RemoveCurrent();
1670
1671 // We were asked to remove only the first association, so bail out.
1672 break;
1673 }
1674 }
1675 return NumRemovedPairs;
1676 }
1677
1686 {
1687 for (typename Super::ElementSetType::TKeyIterator It(Super::Pairs, InKey); It; ++It)
1688 {
1689 if (It->Value == InValue)
1690 {
1691 Super::Pairs.RemoveStable(It.GetId());
1692 return true;
1693 }
1694 }
1695 return false;
1696 }
1697
1707 {
1708 return const_cast<TMULTIMAP*>(this)->FindPair(Key, Value);
1709 }
1710
1720 {
1721 // Iterate over pairs with a matching key.
1722 for (typename Super::ElementSetType::TKeyIterator It(Super::Pairs, Key); It; ++It)
1723 {
1724 // If the pair's value matches, return a pointer to it.
1725 if (It->Value == Value)
1726 {
1727 return &It->Value;
1728 }
1729 }
1730
1731 return nullptr;
1732 }
1733
1736 {
1737 // Iterate over pairs with a matching key.
1739 for (typename Super::ElementSetType::TConstKeyIterator It(Super::Pairs, Key); It; ++It)
1740 {
1742 }
1743 return NumMatchingPairs;
1744 }
1745
1746 // Since we implement an overloaded Num() function in TMULTIMAP, we need to reimplement TMAPBASE::Num to make it visible.
1748 {
1749 return Super::Num();
1750 }
1751
1758 template<typename OtherSetAllocator>
1760 {
1761 this->Reserve(this->Num() + OtherMultiMap.Num());
1762 for (auto& Pair : OtherMultiMap)
1763 {
1764 this->Add(MoveTempIfPossible(Pair.Key), MoveTempIfPossible(Pair.Value));
1765 }
1766
1767 OtherMultiMap.Reset();
1768 }
1769
1776 template<typename OtherSetAllocator>
1778 {
1779 this->Reserve(this->Num() + OtherMultiMap.Num());
1780 for (auto& Pair : OtherMultiMap)
1781 {
1782 this->Add(Pair.Key, Pair.Value);
1783 }
1784 }
1785};
1786
1787namespace Freeze
1788{
1789 template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
1794
1795 template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
1801
1802 template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
1804 {
1806 return DefaultAppendHash(TypeDesc, LayoutParams, Hasher);
1807 }
1808}
1809
1811
1812template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs> struct TIsTMap< TMAP<KeyType, ValueType, SetAllocator, KeyFuncs>> { enum { Value = true }; };
1813template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs> struct TIsTMap<const TMAP<KeyType, ValueType, SetAllocator, KeyFuncs>> { enum { Value = true }; };
1814template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs> struct TIsTMap< volatile TMAP<KeyType, ValueType, SetAllocator, KeyFuncs>> { enum { Value = true }; };
1815template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs> struct TIsTMap<const volatile TMAP<KeyType, ValueType, SetAllocator, KeyFuncs>> { enum { Value = true }; };
1816
1818{
1819 template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
1821 {
1822 Ar << Map.Pairs;
1823 return Ar;
1824 }
1825
1826 template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
1828 {
1829 /*
1830 if (Slot.GetUnderlyingArchive().IsTextFormat())
1831 {
1832 int32 Num = InMap.Num();
1833 FStructuredArchive::FMap Map = Slot.EnterMap(Num);
1834
1835 if (Slot.GetUnderlyingArchive().IsLoading())
1836 {
1837 FString KeyString;
1838 KeyType Key;
1839
1840 for (int32 Index = 0; Index < Num; ++Index)
1841 {
1842 FStructuredArchive::FSlot ValueSlot = Map.EnterElement(KeyString);
1843 LexFromString(Key, *KeyString);
1844 ValueSlot << InMap.Add(Key);
1845 }
1846 }
1847 else
1848 {
1849 FString StringK;
1850 for (TMAPBASE::TIterator It(InMap); It; ++It)
1851 {
1852 StringK = LexToString(It->Key);
1853 FStructuredArchive::FSlot ValueSlot = Map.EnterElement(StringK);
1854 ValueSlot << It->Value;
1855 }
1856 }
1857 }
1858 else
1859 */
1860 {
1861 Slot << InMap.Pairs;
1862 }
1863 }
1864
1865 template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
1867 {
1868 return TSetPrivateFriend::LegacyCompareEqual(A.Pairs, B.Pairs);
1869 }
1870};
1871
1873template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
1875{
1876 return TMAPPRIVATEFRIEND::Serialize(Ar, Map);
1877}
1878
1880template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
1882{
1883 TMAPPRIVATEFRIEND::SerializeStructured(Slot, InMap);
1884}
1885
1886// Legacy comparison operators. Note that these also test whether the map's key-value pairs were added in the same order!
1887template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
1889{
1890 return TMAPPRIVATEFRIEND::LegacyCompareEqual(A, B);
1891}
1892template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
1894{
1895 return !TMAPPRIVATEFRIEND::LegacyCompareEqual(A, B);
1896}
constexpr bool operator!(EUpdateTransformFlags Value)
Definition ActorComponent.h:116
#define check(expr)
Definition AssertionMacros.h:314
#define UE_STATIC_ASSERT_WARN(bExpression, Message)
Definition CoreMiscDefines.h:431
EConstEval
Definition CoreMiscDefines.h:161
@ ConstEval
Definition CoreMiscDefines.h:161
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
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
return true
Definition ExternalRpcRegistry.cpp:601
#define TMAP_STRINGIFY(name)
Definition Map.h.inl:13
#define TMAP
Definition Map.h.inl:9
#define TMULTIMAP
Definition Map.h.inl:11
#define TSORTABLEMAPBASE
Definition Map.h.inl:8
#define TMAPBASE
Definition Map.h.inl:31
UE_FORCEINLINE_HINT FArchive & operator<<(FArchive &Ar, TMAPBASE< KeyType, ValueType, SetAllocator, KeyFuncs > &Map)
Definition Map.h.inl:1874
bool LegacyCompareNotEqual(const TMAPBASE< KeyType, ValueType, SetAllocator, KeyFuncs > &A, const TMAPBASE< KeyType, ValueType, SetAllocator, KeyFuncs > &B)
Definition Map.h.inl:1893
bool LegacyCompareEqual(const TMAPBASE< KeyType, ValueType, SetAllocator, KeyFuncs > &A, const TMAPBASE< KeyType, ValueType, SetAllocator, KeyFuncs > &B)
Definition Map.h.inl:1888
#define DECLARE_TEMPLATE_INTRINSIC_TYPE_LAYOUT(TemplatePrefix, T)
Definition MemoryLayout.h:661
@ Num
Definition MetalRHIPrivate.h:234
const bool
Definition NetworkReplayStreaming.h:178
TIndexedContainerIterator< const TArray< FPreviewAttachedObjectPair >, const FPreviewAttachedObjectPair, int32 > TConstIterator
Definition PreviewAssetAttachComponent.h:69
TIndexedContainerIterator< TArray< FPreviewAttachedObjectPair >, FPreviewAttachedObjectPair, int32 > TIterator
Definition PreviewAssetAttachComponent.h:68
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTempIfPossible(T &&Obj) noexcept
Definition UnrealTemplate.h:538
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 Archive.h:1208
Definition MemoryImageWriter.h:14
Definition MemoryImageWriter.h:78
Definition OutputDevice.h:133
Definition SecureHash.h:314
Definition SetUtilities.h:95
Definition StructuredArchiveSlots.h:52
Definition Array.h:670
Definition Map.h:57
Definition Map.h.inl:769
UE_FORCEINLINE_HINT PairType & operator*() const
Definition Map.h.inl:827
UE_FORCEINLINE_HINT ItValueType & Value() const
Definition Map.h.inl:817
UE_FORCEINLINE_HINT ItKeyType & Key() const
Definition Map.h.inl:813
UE_FORCEINLINE_HINT PairType * operator->() const
Definition Map.h.inl:831
UE_FORCEINLINE_HINT TBaseIterator(const PairItType &InElementIt)
Definition Map.h.inl:782
PairItType PairIt
Definition Map.h.inl:837
UE_FORCEINLINE_HINT bool operator!=(const TBaseIterator &Rhs) const
Definition Map.h.inl:808
UE_FORCEINLINE_HINT bool operator==(const TBaseIterator &Rhs) const
Definition Map.h.inl:804
UE_FORCEINLINE_HINT TBaseIterator & operator++()
Definition Map.h.inl:787
UE_FORCEINLINE_HINT FSetElementId GetId() const
Definition Map.h.inl:822
std::conditional_t< bConst, typename ElementSetType::TConstIterator, typename ElementSetType::TIterator > PairItType
Definition Map.h.inl:775
Definition Map.h.inl:843
UE_FORCEINLINE_HINT ItKeyType & Key() const
Definition Map.h.inl:877
UE_FORCEINLINE_HINT TBaseKeyIterator & operator++()
Definition Map.h.inl:856
SetItType SetIt
Definition Map.h.inl:896
UE_FORCEINLINE_HINT ItValueType & Value() const
Definition Map.h.inl:881
UE_FORCEINLINE_HINT TBaseKeyIterator(const SetItType &InSetIt)
Definition Map.h.inl:851
UE_FORCEINLINE_HINT FSetElementId GetId() const
Definition Map.h.inl:873
Definition Map.h.inl:959
UE_FORCEINLINE_HINT TConstIterator(const TMAPBASE &InMap)
Definition Map.h.inl:961
Definition Map.h.inl:972
typename IteratorType::KeyArgumentType KeyArgumentType
Definition Map.h.inl:978
UE_FORCEINLINE_HINT TConstKeyIterator(const TMAPBASE &InMap, KeyArgumentType InKey)
Definition Map.h.inl:980
Definition Map.h.inl:920
void RemoveCurrent()
Definition Map.h.inl:945
TIterator(TMAPBASE &InMap, bool bInRequiresRehashOnRemoval=false)
Definition Map.h.inl:924
~TIterator()
Definition Map.h.inl:933
Definition Map.h.inl:988
UE_FORCEINLINE_HINT void RemoveCurrent()
Definition Map.h.inl:1002
UE_FORCEINLINE_HINT TKeyIterator(TMAPBASE &InMap, KeyArgumentType InKey)
Definition Map.h.inl:996
typename IteratorType::KeyArgumentType KeyArgumentType
Definition Map.h.inl:994
Definition Map.h.inl:29
UE_FORCEINLINE_HINT int32 Num() const
Definition Map.h.inl:194
typename ElementSetType::TRangedForIterator TRangedForIterator
Definition Map.h.inl:967
UE_FORCEINLINE_HINT TKeyIterator CreateKeyIterator(typename TKeyIterator::KeyArgumentType InKey)
Definition Map.h.inl:1021
TSET< ElementType, KeyFuncs, SetAllocator > ElementSetType
Definition Map.h.inl:764
TMAPBASE(const TMAPBASE &)=default
UE_FORCEINLINE_HINT ValueType & AddByHash(uint32 KeyHash, const KeyType &InKey, ValueType &&InValue)
Definition Map.h.inl:327
TMAPBASE & operator=(const TMAPBASE &)=default
UE_FORCEINLINE_HINT FSetElementId FindId(KeyInitType Key) const
Definition Map.h.inl:536
UE_FORCEINLINE_HINT TIterator CreateIterator()
Definition Map.h.inl:1009
ValueType & Emplace(InitKeyType &&InKey, InitValueType &&InValue)
Definition Map.h.inl:361
ValueType * Find(KeyConstPointerType Key)
Definition Map.h.inl:486
UE_FORCEINLINE_HINT FSetElementId FindIdByHash(uint32 KeyHash, const ComparableKey &Key) const
Definition Map.h.inl:543
void Dump(FOutputDevice &Ar)
Definition Map.h.inl:758
TMAP< KeyType, ValueType, SetAllocator, KeyFuncs > FilterByPredicate(Predicate Pred) const
Definition Map.h.inl:465
typename ElementSetType::TRangedForConstIterator TRangedForConstIterator
Definition Map.h.inl:968
ElementSetType Pairs
Definition Map.h.inl:900
UE_FORCEINLINE_HINT void Reserve(int32 Number)
Definition Map.h.inl:177
UE_FORCEINLINE_HINT ValueType & FindOrAddByHash(uint32 KeyHash, KeyType &&Key)
Definition Map.h.inl:605
ValueType & EmplaceByHash(uint32 KeyHash, InitKeyType &&InKey, InitValueType &&InValue)
Definition Map.h.inl:370
UE_FORCEINLINE_HINT void Empty(int32 ExpectedNumElements=0)
Definition Map.h.inl:147
UE_FORCEINLINE_HINT ValueType & FindOrAddByHash(uint32 KeyHash, const KeyType &Key, ValueType &&Value)
Definition Map.h.inl:622
UE_FORCEINLINE_HINT SIZE_T GetAllocatedSize() const
Definition Map.h.inl:297
UE_FORCEINLINE_HINT ValueType & FindOrAddByHash(uint32 KeyHash, const KeyType &Key)
Definition Map.h.inl:604
ValueType & Emplace(InitKeyType &&InKey)
Definition Map.h.inl:384
consteval TMAPBASE(EConstEval)
Definition Map.h.inl:41
friend bool operator!=(const TMAPBASE &, const TMAPBASE &)=delete
UE_FORCEINLINE_HINT void CountBytes(FArchive &Ar) const
Definition Map.h.inl:308
UE_FORCEINLINE_HINT void CompactStable()
Definition Map.h.inl:171
UE_FORCEINLINE_HINT ValueType & Add(KeyType &&InKey, ValueType &&InValue)
Definition Map.h.inl:323
void GenerateValueArray(TArray< ValueType, Allocator > &OutArray) const
Definition Map.h.inl:744
ValueType * FindByHash(uint32 KeyHash, const ComparableKey &Key)
Definition Map.h.inl:502
UE_FORCEINLINE_HINT int32 GetMaxIndex() const
Definition Map.h.inl:206
TTypeTraits< KeyType >::ConstPointerType KeyConstPointerType
Definition Map.h.inl:34
UE_FORCEINLINE_HINT const ValueType & FindByHashChecked(uint32 KeyHash, const ComparableKey &Key) const
Definition Map.h.inl:525
TMAPBASE(TMAPBASE &&)=default
static void AppendHash(const FPlatformTypeLayoutParameters &LayoutParams, FSHA1 &Hasher)
Definition Map.h.inl:913
TTypeTraits< ValueType >::ConstInitType ValueInitType
Definition Map.h.inl:36
UE_FORCEINLINE_HINT bool IsValidId(FSetElementId Id) const
Definition Map.h.inl:216
UE_FORCEINLINE_HINT ValueType & FindOrAdd(const KeyType &Key, ValueType &&Value)
Definition Map.h.inl:616
UE_FORCEINLINE_HINT bool Contains(KeyConstPointerType Key) const
Definition Map.h.inl:707
int32 RemoveStable(KeyConstPointerType InKey)
Definition Map.h.inl:412
TArray< ElementType > Array() const
Definition Map.h.inl:720
const ElementType * FindArbitraryElement() const
Definition Map.h.inl:696
const ValueType & FindChecked(KeyConstPointerType Key) const
Definition Map.h.inl:632
friend uint32 GetTypeHash(const TMAPBASE &Map)=delete
TMAPBASE & operator=(const TMAPBASE< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &Other)
Definition Map.h.inl:97
friend bool operator==(const TMAPBASE &, const TMAPBASE &)=delete
void GenerateKeyArray(TArray< KeyType, Allocator > &OutArray) const
Definition Map.h.inl:730
TMAPBASE(FIntrusiveUnsetOptionalState Tag)
Definition Map.h.inl:75
UE_FORCEINLINE_HINT TConstKeyIterator CreateConstKeyIterator(typename TConstKeyIterator::KeyArgumentType InKey) const
Definition Map.h.inl:1027
TMAPBASE & operator=(TMAPBASE< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &&Other)
Definition Map.h.inl:89
UE_FORCEINLINE_HINT ValueType & FindOrAdd(const KeyType &Key, const ValueType &Value)
Definition Map.h.inl:615
~TMAPBASE()
Definition Map.h.inl:64
UE_FORCEINLINE_HINT ValueType & Add(const KeyType &InKey)
Definition Map.h.inl:337
UE_FORCEINLINE_HINT ValueType & AddByHash(uint32 KeyHash, KeyType &&InKey)
Definition Map.h.inl:342
UE_FORCEINLINE_HINT ValueType & FindOrAdd(KeyType &&Key, const ValueType &Value)
Definition Map.h.inl:617
UE_FORCEINLINE_HINT ValueType & FindOrAdd(const KeyType &Key)
Definition Map.h.inl:600
UE_FORCEINLINE_HINT ValueType & AddByHash(uint32 KeyHash, KeyType &&InKey, const ValueType &InValue)
Definition Map.h.inl:328
UE_FORCEINLINE_HINT TRangedForConstIterator begin() const
Definition Map.h.inl:1040
TMAPBASE(TMAPBASE< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &&Other)
Definition Map.h.inl:52
bool OrderIndependentCompareEqual(const TMAPBASE &Other) const
Definition Map.h.inl:113
UE_FORCEINLINE_HINT ValueType & Add(const KeyType &InKey, const ValueType &InValue)
Definition Map.h.inl:320
UE_FORCEINLINE_HINT const ValueType * Find(KeyConstPointerType Key) const
Definition Map.h.inl:495
UE_FORCEINLINE_HINT TConstIterator CreateConstIterator() const
Definition Map.h.inl:1015
UE_FORCEINLINE_HINT const ValueType * FindByHash(uint32 KeyHash, const ComparableKey &Key) const
Definition Map.h.inl:512
UE_FORCEINLINE_HINT ValueType & Add(const KeyType &InKey, ValueType &&InValue)
Definition Map.h.inl:321
UE_FORCEINLINE_HINT ValueType & Add(KeyType &&InKey)
Definition Map.h.inl:338
ValueType FindRef(KeyConstPointerType Key, ValueType DefaultValue) const
Definition Map.h.inl:675
UE_FORCEINLINE_HINT ValueType & AddByHash(uint32 KeyHash, const KeyType &InKey, const ValueType &InValue)
Definition Map.h.inl:326
int32 GetKeys(TArray< KeyType, Allocator > &OutKeys) const
Definition Map.h.inl:239
UE_FORCEINLINE_HINT ElementType & Get(FSetElementId Id)
Definition Map.h.inl:222
UE_FORCEINLINE_HINT const ElementType & Get(FSetElementId Id) const
Definition Map.h.inl:228
bool IsEmpty() const
Definition Map.h.inl:188
UE_FORCEINLINE_HINT TRangedForIterator end()
Definition Map.h.inl:1041
UE_FORCEINLINE_HINT void Shrink()
Definition Map.h.inl:159
TMAPBASE & operator=(TMAPBASE &&)=default
void WriteMemoryImage(FMemoryImageWriter &Writer) const
Definition Map.h.inl:903
UE_FORCEINLINE_HINT void Reset()
Definition Map.h.inl:153
UE_FORCEINLINE_HINT ValueType & FindOrAddByHash(uint32 KeyHash, const KeyType &Key, const ValueType &Value)
Definition Map.h.inl:621
UE_FORCEINLINE_HINT ValueType & Add(const TTuple< KeyType, ValueType > &InKeyValue)
Definition Map.h.inl:350
UE_FORCEINLINE_HINT ValueType & AddByHash(uint32 KeyHash, KeyType &&InKey, ValueType &&InValue)
Definition Map.h.inl:329
ElementType * FindArbitraryElement()
Definition Map.h.inl:690
UE_FORCEINLINE_HINT ValueType & FindOrAdd(KeyType &&Key)
Definition Map.h.inl:601
TTypeTraits< KeyType >::ConstInitType KeyInitType
Definition Map.h.inl:35
UE_FORCEINLINE_HINT bool ContainsByHash(uint32 KeyHash, const ComparableKey &Key) const
Definition Map.h.inl:714
UE_FORCEINLINE_HINT ValueType & Add(TTuple< KeyType, ValueType > &&InKeyValue)
Definition Map.h.inl:351
UE_FORCEINLINE_HINT ValueType & FindOrAddByHash(uint32 KeyHash, KeyType &&Key, ValueType &&Value)
Definition Map.h.inl:624
ValueType & FindChecked(KeyConstPointerType Key)
Definition Map.h.inl:645
UE_FORCEINLINE_HINT ValueType & AddByHash(uint32 KeyHash, const KeyType &InKey)
Definition Map.h.inl:341
UE_FORCEINLINE_HINT TRangedForConstIterator end() const
Definition Map.h.inl:1042
UE_FORCEINLINE_HINT int32 Max() const
Definition Map.h.inl:200
int32 Remove(KeyConstPointerType InKey)
Definition Map.h.inl:406
UE_FORCEINLINE_HINT ValueType & FindOrAdd(KeyType &&Key, ValueType &&Value)
Definition Map.h.inl:618
TPair< KeyType, ValueType > ElementType
Definition Map.h.inl:37
UE_FORCEINLINE_HINT ValueType & Add(KeyType &&InKey, const ValueType &InValue)
Definition Map.h.inl:322
ValueType & FindByHashChecked(uint32 KeyHash, const ComparableKey &Key)
Definition Map.h.inl:518
ValueType FindRef(KeyConstPointerType Key) const
Definition Map.h.inl:658
UE_FORCEINLINE_HINT ValueType & FindOrAddByHash(uint32 KeyHash, KeyType &&Key, const ValueType &Value)
Definition Map.h.inl:623
static constexpr bool bHasIntrusiveUnsetOptionalState
Definition Map.h.inl:72
void CopyUnfrozen(const FMemoryUnfreezeContent &Context, void *Dst) const
Definition Map.h.inl:908
UE_FORCEINLINE_HINT void Compact()
Definition Map.h.inl:165
UE_FORCEINLINE_HINT TRangedForIterator begin()
Definition Map.h.inl:1039
TMAPBASE(const TMAPBASE< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &Other)
Definition Map.h.inl:59
bool operator==(FIntrusiveUnsetOptionalState Tag) const
Definition Map.h.inl:79
ValueType & EmplaceByHash(uint32 KeyHash, InitKeyType &&InKey)
Definition Map.h.inl:393
const KeyType * FindKey(ValueInitType Value) const
Definition Map.h.inl:445
constexpr TMAPBASE()=default
int32 GetKeys(TSet< KeyType, InSetKeyFuncs, InSetAllocator > &OutKeys) const
Definition Map.h.inl:272
int32 RemoveByHash(uint32 KeyHash, const ComparableKey &Key)
Definition Map.h.inl:420
UE_FORCEINLINE_HINT void Remove(FSetElementId Id)
Definition Map.h.inl:430
Definition Map.h.inl:1210
Super::KeyInitType KeyInitType
Definition Map.h.inl:1223
constexpr TMAP()=default
TSORTABLEMAPBASE< KeyType, ValueType, SetAllocator, KeyFuncs > Super
Definition Map.h.inl:1222
TMAP & operator=(std::initializer_list< TPairInitializer< const KeyType &, const ValueType & > > InitList)
Definition Map.h.inl:1295
bool RemoveAndCopyValueByHash(uint32 KeyHash, const ComparableKey &Key, ValueType &OutRemovedValue)
Definition Map.h.inl:1342
consteval TMAP(EConstEval)
Definition Map.h.inl:1227
SetAllocator SetAllocatorType
Definition Map.h.inl:1219
void Append(const TMAP< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &OtherMap)
Definition Map.h.inl:1397
void Append(TMAP< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &&OtherMap)
Definition Map.h.inl:1379
TMAP(FIntrusiveUnsetOptionalState Tag)
Definition Map.h.inl:1266
Super::KeyConstPointerType KeyConstPointerType
Definition Map.h.inl:1224
TMAP(TMAP< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &&Other)
Definition Map.h.inl:1238
ValueType FindAndRemoveChecked(KeyConstPointerType Key)
Definition Map.h.inl:1363
InKeyType KeyType
Definition Map.h.inl:1217
TMAP & operator=(const TMAP &)=default
bool RemoveAndCopyValue(KeyInitType Key, ValueType &OutRemovedValue)
Definition Map.h.inl:1313
UE_FORCEINLINE_HINT const ValueType & operator[](KeyConstPointerType Key) const
Definition Map.h.inl:1410
UE_FORCEINLINE_HINT ValueType & operator[](KeyConstPointerType Key)
Definition Map.h.inl:1406
TMAP(const TMAP< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &Other)
Definition Map.h.inl:1245
TMAP(std::initializer_list< TPairInitializer< const KeyType &, const ValueType & > > InitList)
Definition Map.h.inl:1251
TMAP(TMAP &&)=default
TMAP & operator=(const TMAP< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &Other)
Definition Map.h.inl:1288
bool RemoveAndCopyValueStable(KeyInitType Key, ValueType &OutRemovedValue)
Definition Map.h.inl:1327
TMAP(const TMAP &)=default
TMAP & operator=(TMAP< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &&Other)
Definition Map.h.inl:1280
InValueType ValueType
Definition Map.h.inl:1218
TMAP & operator=(TMAP &&)=default
bool operator==(FIntrusiveUnsetOptionalState Tag) const
Definition Map.h.inl:1270
KeyFuncs KeyFuncsType
Definition Map.h.inl:1220
Definition Map.h.inl:1444
UE_FORCEINLINE_HINT ValueType & AddUnique(const KeyType &InKey, ValueType &&InValue)
Definition Map.h.inl:1591
TMULTIMAP & operator=(const TMULTIMAP &)=default
TMULTIMAP(TMULTIMAP &&)=default
void Append(const TMULTIMAP< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &OtherMultiMap)
Definition Map.h.inl:1777
void MultiFindPointer(KeyInitType Key, TArray< const ValueType *, Allocator > &OutValues, bool bMaintainOrder=false) const
Definition Map.h.inl:1556
Super::KeyConstPointerType KeyConstPointerType
Definition Map.h.inl:1449
Super::KeyInitType KeyInitType
Definition Map.h.inl:1450
TMULTIMAP & operator=(TMULTIMAP &&)=default
constexpr TMULTIMAP()=default
int32 Num(KeyInitType Key) const
Definition Map.h.inl:1735
UE_FORCEINLINE_HINT int32 Num() const
Definition Map.h.inl:1747
TMULTIMAP & operator=(std::initializer_list< TPairInitializer< const KeyType &, const ValueType & > > InitList)
Definition Map.h.inl:1518
TMULTIMAP & operator=(TMULTIMAP< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &&Other)
Definition Map.h.inl:1503
UE_FORCEINLINE_HINT const ValueType * FindPair(KeyInitType Key, ValueInitType Value) const
Definition Map.h.inl:1706
void MultiFind(KeyInitType Key, TArray< ValueType, Allocator > &OutValues, bool bMaintainOrder=false) const
Definition Map.h.inl:1535
TMULTIMAP(const TMULTIMAP< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &Other)
Definition Map.h.inl:1468
ValueType * FindPair(KeyInitType Key, ValueInitType Value)
Definition Map.h.inl:1719
Super::ValueInitType ValueInitType
Definition Map.h.inl:1451
UE_FORCEINLINE_HINT ValueType & AddUnique(KeyType &&InKey, ValueType &&InValue)
Definition Map.h.inl:1593
TSORTABLEMAPBASE< KeyType, ValueType, SetAllocator, KeyFuncs > Super
Definition Map.h.inl:1448
int32 Remove(KeyInitType InKey, ValueInitType InValue)
Definition Map.h.inl:1636
TMULTIMAP(std::initializer_list< TPairInitializer< const KeyType &, const ValueType & > > InitList)
Definition Map.h.inl:1474
void Append(TMULTIMAP< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &&OtherMultiMap)
Definition Map.h.inl:1759
UE_FORCEINLINE_HINT ValueType & AddUnique(const KeyType &InKey, const ValueType &InValue)
Definition Map.h.inl:1590
int32 RemoveSingle(KeyInitType InKey, ValueInitType InValue)
Definition Map.h.inl:1659
ValueType & EmplaceUnique(InitKeyType &&InKey, InitValueType &&InValue)
Definition Map.h.inl:1607
TMULTIMAP & operator=(const TMULTIMAP< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &Other)
Definition Map.h.inl:1511
TMULTIMAP(FIntrusiveUnsetOptionalState Tag)
Definition Map.h.inl:1489
TMULTIMAP(TMULTIMAP< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &&Other)
Definition Map.h.inl:1461
UE_FORCEINLINE_HINT ValueType & AddUnique(KeyType &&InKey, const ValueType &InValue)
Definition Map.h.inl:1592
bool RemoveSingleStable(KeyInitType InKey, ValueInitType InValue)
Definition Map.h.inl:1685
bool operator==(FIntrusiveUnsetOptionalState Tag) const
Definition Map.h.inl:1493
UE_FORCEINLINE_HINT int32 Remove(KeyConstPointerType InKey)
Definition Map.h.inl:1624
void MultiFindPointer(KeyInitType Key, TArray< ValueType *, Allocator > &OutValues, bool bMaintainOrder=false)
Definition Map.h.inl:1568
TMULTIMAP(const TMULTIMAP &)=default
Definition Map.h:26
Definition Map.h.inl:1053
constexpr TSORTABLEMAPBASE()=default
TSORTABLEMAPBASE(const TSORTABLEMAPBASE &)=default
UE_FORCEINLINE_HINT void KeyStableSort(const PREDICATE_CLASS &Predicate)
Definition Map.h.inl:1131
TSORTABLEMAPBASE & operator=(const TSORTABLEMAPBASE< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &Other)
Definition Map.h.inl:1091
TSORTABLEMAPBASE(TSORTABLEMAPBASE &&)=default
UE_FORCEINLINE_HINT void ValueSort(const PREDICATE_CLASS &Predicate)
Definition Map.h.inl:1141
TSORTABLEMAPBASE & operator=(TSORTABLEMAPBASE &&)=default
TSORTABLEMAPBASE(FIntrusiveUnsetOptionalState Tag)
Definition Map.h.inl:1103
TSORTABLEMAPBASE & operator=(const TSORTABLEMAPBASE &)=default
TMAPBASE< KeyType, ValueType, SetAllocator, KeyFuncs > Super
Definition Map.h.inl:1055
bool operator==(FIntrusiveUnsetOptionalState Tag) const
Definition Map.h.inl:1107
TSORTABLEMAPBASE(const TSORTABLEMAPBASE< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &Other)
Definition Map.h.inl:1076
TSORTABLEMAPBASE(TSORTABLEMAPBASE< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &&Other)
Definition Map.h.inl:1069
consteval TSORTABLEMAPBASE(EConstEval)
Definition Map.h.inl:1058
UE_FORCEINLINE_HINT void KeySort(const PREDICATE_CLASS &Predicate)
Definition Map.h.inl:1121
UE_FORCEINLINE_HINT void ValueStableSort(const PREDICATE_CLASS &Predicate)
Definition Map.h.inl:1151
TSORTABLEMAPBASE & operator=(TSORTABLEMAPBASE< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &&Other)
Definition Map.h.inl:1083
void SortFreeList()
Definition Map.h.inl:1161
Definition Map.h:152
UE_REWRITE void Reverse(T(&Array)[ArraySize])
Definition Reverse.h:28
Definition Array.h:3955
UE_NODEBUG void IntrinsicWriteMemoryImage(FMemoryImageWriter &Writer, const TArray< T, AllocatorType > &Object, const FTypeLayoutDesc &)
Definition Array.h:3957
CORE_API uint32 DefaultAppendHash(const FTypeLayoutDesc &TypeDesc, const FPlatformTypeLayoutParameters &LayoutParams, FSHA1 &Hasher)
Definition MemoryImage.cpp:575
UE_NODEBUG uint32 IntrinsicUnfrozenCopy(const FMemoryUnfreezeContent &Context, const TArray< T, AllocatorType > &Object, void *OutDst)
Definition Array.h:3963
UE_NODEBUG uint32 IntrinsicAppendHash(const TArray< T, AllocatorType > *DummyObject, const FTypeLayoutDesc &TypeDesc, const FPlatformTypeLayoutParameters &LayoutParams, FSHA1 &Hasher)
Definition Array.h:3970
FNameFuncs< typename TGetKeyType< MapType >::Type > KeyFuncs
Definition PerPlatformProperties.h:107
@ false
Definition radaudio_common.h:23
Definition IntrusiveUnsetOptionalState.h:71
Definition MemoryLayout.h:799
Definition MemoryLayout.h:108
Definition Sorting.h:16
Definition Map.h:125
@ Value
Definition Map.h:125
Definition Map.h.inl:1818
static FArchive & Serialize(FArchive &Ar, TMAPBASE< KeyType, ValueType, SetAllocator, KeyFuncs > &Map)
Definition Map.h.inl:1820
static bool LegacyCompareEqual(const TMAPBASE< KeyType, ValueType, SetAllocator, KeyFuncs > &A, const TMAPBASE< KeyType, ValueType, SetAllocator, KeyFuncs > &B)
Definition Map.h.inl:1866
static UE_FORCEINLINE_HINT void SerializeStructured(FStructuredArchive::FSlot Slot, TMAPBASE< KeyType, ValueType, SetAllocator, KeyFuncs > &InMap)
Definition Map.h.inl:1827
Definition Tuple.h:652
TCallTraits< T >::ParamType ConstInitType
Definition UnrealTypeTraits.h:336
TCallTraits< T >::ConstPointerType ConstPointerType
Definition UnrealTypeTraits.h:337