UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UniquePointerSet.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
7
8namespace uLang
9{
10
15template<typename InElementType, bool AllowNull, typename InKeyType, typename InElementAllocatorType, typename... RawAllocatorArgsType>
17 : protected TUPtrArrayG<InElementType, AllowNull, InElementAllocatorType, RawAllocatorArgsType...>
18{
19 template <typename OtherElementType, bool OtherAllowNull, typename OtherKeyType, typename OtherElementAllocatorType, typename... OtherRawAllocatorArgsType>
20 friend class TUPtrSetG;
21
25
26public:
27
31
38
48
57 : Super(ForwardArg<Super>(Other), ExtraSlack)
58 {
59 }
60
61 // Use these superclass methods as-is:
62 using Super::operator=;
63 using Super::GetSlack;
65 using Super::Num;
66 using Super::Max;
67 using Super::IsEmpty;
68 using Super::IsFilled;
69 using Super::operator[];
70 using Super::Shrink;
71 using Super::RemoveAt;
72 using Super::ReplaceAt;
73 using Super::Reset;
74 using Super::Empty;
75 using Super::Reserve;
76 using Super::begin;
77 using Super::end;
78
86 int32_t IndexOf(const KeyType& Key) const
87 {
89 return (UpperBound < Num() && KeyType(*_PointerStorage[UpperBound]) == Key) ? UpperBound : IndexNone;
90 }
91
101 {
103 if (UpperBound < Num())
104 {
105 ElementType* Item = _PointerStorage[UpperBound];
106 if (KeyType(*Item) == Key)
107 {
108 return Item;
109 }
110 }
111 return nullptr;
112 }
113
120 bool Contains(const KeyType& Key) const
121 {
123 return UpperBound < Num() && KeyType(*_PointerStorage[UpperBound]) == Key;
124 }
125
134 void Append(const TUPtrSetG& Other)
135 {
136 Other.ReferenceAll();
137 Merge(_PointerStorage, Other._PointerStorage);
138 }
139
147 {
148 Merge(_PointerStorage, Other._PointerStorage);
149 Other.Empty();
150 }
151
161 {
163 return *this;
164 }
165
173 {
174 Append(Other);
175 return *this;
176 }
177
184 template <typename... CtorArgsType>
186 {
187 ElementType * Item = new(_PointerStorage.GetRawAllocator()) ElementType(uLang::ForwardArg<CtorArgsType>(CtorArgs)...);
188 int32_t UpperBound = Helper::GetUpperBound(_PointerStorage, *Item);
189 ULANG_ASSERTF(UpperBound == Num() || KeyType(*_PointerStorage[UpperBound]) != KeyType(*Item), "Tried to add duplicate item!");
190 _PointerStorage.EmplaceAt(UpperBound, Item);
191 return UpperBound;
192 }
193
204 {
205 int32_t UpperBound = Helper::GetUpperBound(_PointerStorage, *Item);
206 ULANG_ASSERTF(UpperBound == Num() || KeyType(*_PointerStorage[UpperBound]) != KeyType(*Item), "Tried to add duplicate item!");
207 return Super::Insert(ForwardArg<PointerType>(Item), UpperBound);
208 }
209
219 {
220 int32_t Count = 0;
222 if (UpperBound < Num() && KeyType(*_PointerStorage[UpperBound]) == Key)
223 {
224 Super::RemoveAt(UpperBound);
225 ++Count;
226 }
227 ULANG_ASSERTF(UpperBound == Num() || KeyType(*_PointerStorage[UpperBound]) != Key, "Matching item still present after Remove()!");
228 return Count;
229 }
230
231};
232
234template<typename ElementType, typename KeyType>
236
238template<typename ElementType, typename KeyType>
240
242template<typename ElementType, typename KeyType>
244
246template<typename ElementType, typename KeyType>
248
249
250template <typename ElementType, bool AllowNull, typename KeyType, typename ElementAllocatorType, typename... RawAllocatorArgsType>
251struct TIsZeroConstructType<TUPtrSetG<ElementType, AllowNull, KeyType, ElementAllocatorType, RawAllocatorArgsType...>>
252{
254};
255
256template <typename ElementType, bool AllowNull, typename KeyType, typename ElementAllocatorType, typename... RawAllocatorArgsType>
257struct TContainerTraits<TUPtrSetG<ElementType, AllowNull, KeyType, ElementAllocatorType, RawAllocatorArgsType...>> : public TContainerTraitsBase<TUPtrSetG<ElementType, AllowNull, ElementAllocatorType, RawAllocatorArgsType...>>
258{
259 static_assert(TAllocatorTraits<ElementAllocatorType>::SupportsMove, "TUPtrArray no longer supports move-unaware allocators");
261};
262
263template <typename ElementType, bool AllowNull, typename KeyType, typename ElementAllocatorType, typename... RawAllocatorArgsType>
264struct TIsContiguousContainer<TUPtrSetG<ElementType, AllowNull, KeyType, ElementAllocatorType, RawAllocatorArgsType...>>
265{
266 enum { Value = true };
267};
268
269}
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ULANG_FORCEINLINE
Definition Common.h:188
#define ULANG_ASSERTF(expr, format,...)
Definition Common.h:290
Definition Allocator.h:35
ULANG_FORCEINLINE void EmplaceAt(int32_t Index, ArgsType &&... Args)
Definition Array.h:1556
ULANG_FORCEINLINE const ElementAllocatorType::RawAllocatorType & GetRawAllocator() const
Definition Array.h:419
Definition PointerSetHelper.h:15
static int32_t GetUpperBound(const PointerStorageType &This, const KeyType &Key)
Definition PointerSetHelper.h:21
Definition UniquePointerArray.h:16
ULANG_FORCEINLINE int32_t Max() const
Definition UniquePointerArray.h:115
int32_t Insert(TUPtrArrayG &&Items, const int32_t InIndex)
Definition UniquePointerArray.h:393
ULANG_FORCEINLINE ElementType ** end()
Definition UniquePointerArray.h:725
ULANG_FORCEINLINE ElementType ** begin()
Definition UniquePointerArray.h:723
ULANG_FORCEINLINE PointerType RemoveAt(int32_t Index)
Definition UniquePointerArray.h:419
ULANG_FORCEINLINE int32_t GetSlack() const
Definition UniquePointerArray.h:82
ULANG_FORCEINLINE void Reserve(int32_t Number)
Definition UniquePointerArray.h:641
TUPtrG< ElementType, AllowNull, typename InElementAllocatorType::RawAllocatorType, RawAllocatorArgsType... > PointerType
Definition UniquePointerArray.h:24
ULANG_FORCEINLINE int32_t Num() const
Definition UniquePointerArray.h:104
ULANG_FORCEINLINE bool IsEmpty() const
Definition UniquePointerArray.h:126
ULANG_FORCEINLINE bool IsValidIndex(int32_t Index) const
Definition UniquePointerArray.h:93
int32_t ReplaceAt(PointerType &&Item, int32_t Index)
Definition UniquePointerArray.h:487
ULANG_FORCEINLINE bool IsFilled() const
Definition UniquePointerArray.h:137
Definition UniquePointer.h:15
Definition UniquePointerSet.h:18
void Append(TUPtrSetG &&Other)
Definition UniquePointerSet.h:146
TUPtrSetG & operator+=(const TUPtrSetG &Other)
Definition UniquePointerSet.h:172
ULANG_FORCEINLINE TUPtrSetG(RawAllocatorArgsType &&... RawAllocatorArgs)
Definition UniquePointerSet.h:35
ULANG_FORCEINLINE TUPtrSetG(TUPtrSetG &&Other)
Definition UniquePointerSet.h:44
void Append(const TUPtrSetG &Other)
Definition UniquePointerSet.h:134
TUPtrSetG(TUPtrSetG &&Other, int32_t ExtraSlack)
Definition UniquePointerSet.h:56
TUPtrSetG & operator+=(TUPtrSetG &&Other)
Definition UniquePointerSet.h:160
ULANG_FORCEINLINE ElementType * Find(const KeyType &Key) const
Definition UniquePointerSet.h:100
ULANG_FORCEINLINE int32_t AddNew(CtorArgsType &&... CtorArgs)
Definition UniquePointerSet.h:185
bool Contains(const KeyType &Key) const
Definition UniquePointerSet.h:120
InKeyType KeyType
Definition UniquePointerSet.h:28
ULANG_FORCEINLINE int32_t Add(PointerType &&Item)
Definition UniquePointerSet.h:203
int32_t IndexOf(const KeyType &Key) const
Definition UniquePointerSet.h:86
int32_t Remove(const KeyType &Key)
Definition UniquePointerSet.h:218
Definition VVMEngineEnvironment.h:23
@ IndexNone
Definition Common.h:381
ULANG_FORCEINLINE T && ForwardArg(typename TRemoveReference< T >::Type &Obj)
Definition References.h:115
Definition Allocator.h:238
Definition TypeTraits.h:451
@ MoveWillEmptyContainer
Definition TypeTraits.h:453
Definition TypeTraits.h:456
Definition TypeTraits.h:263
@ Value
Definition TypeTraits.h:264
Definition TypeTraits.h:325