UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PointerSetHelper.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
13template<typename ElementType, typename KeyType>
15{
16public:
17
19
20 // Merge other sorted array into this array
21 static int32_t GetUpperBound(const PointerStorageType& This, const KeyType& Key)
22 {
23 int32_t Lo = 0;
24 int32_t Hi = This.Num();
25 ElementType const * const * Elements = This.GetData();
26 if (Hi > 0)
27 {
28 while (true)
29 {
30 int32_t Mid = (Lo + Hi) >> 1;
31 if (KeyType(*Elements[Mid]) < Key)
32 {
33 if (Mid == Lo) break;
34 Lo = Mid;
35 }
36 else
37 {
38 Hi = Mid;
39 if (Mid == Lo) break;
40 }
41 }
42 }
43 return Hi;
44 }
45
46 // Merge other sorted array into this array
48 {
49 // Begin from end and move backwards
50 int32_t SrcIndexThis = This.Num() - 1;
51 int32_t SrcIndexOther = Other.Num() - 1;
52 This.ResizeTo(This.Num() + Other.Num());
53 ElementType* ItemThis = SrcIndexThis >= 0 ? This[SrcIndexThis] : nullptr;
54 ElementType* ItemOther = SrcIndexOther >= 0 ? Other[SrcIndexOther] : nullptr;
55 for (int32_t DstIndex = This.Num() - 1; DstIndex >= 0; --DstIndex)
56 {
57 ElementType* Item;
58 if (ItemThis && (!ItemOther || KeyType(*ItemThis) > KeyType(*ItemOther)))
59 {
60 Item = ItemThis;
62 ItemThis = SrcIndexThis >= 0 ? This[SrcIndexThis] : nullptr;
63 }
64 else
65 {
66 Item = ItemOther;
68 ItemOther = SrcIndexOther >= 0 ? Other[SrcIndexOther] : nullptr;
69 }
70 This[DstIndex] = Item;
71 }
72 }
73};
74
75}
76
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition Array.h:51
Definition PointerSetHelper.h:15
static void Merge(PointerStorageType &This, const PointerStorageType &Other)
Definition PointerSetHelper.h:47
static int32_t GetUpperBound(const PointerStorageType &This, const KeyType &Key)
Definition PointerSetHelper.h:21
Definition VVMEngineEnvironment.h:23