UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Array.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
5
6#if !COMPILE_WITHOUT_UNREAL_SUPPORT
7#include "Containers/Array.h"
8#else
9#include <vector>
10
11template<class T>
12class TArray : public std::vector<T>
13{
14 public:
15 TArray()
16 : std::vector<T>() {}
18 : std::vector<T>(std::move(Other)) {}
19 TArray(const TArray<T>& Other)
20 : std::vector<T>(Other) {}
21 TArray(std::initializer_list<T> l)
22 : std::vector<T>(l) {}
24 {
25 std::vector<T>::operator=(std::move(Other));
26 }
27 void SetNum(const int32 Size)
28 {
29 std::vector<T>::resize(Size);
30 }
31 int32 Num() const
32 {
33 return static_cast<int32>(std::vector<T>::size());
34 }
35 void Add(const T& Elem)
36 {
37 std::vector<T>::push_back(Elem);
38 }
39 void Sort()
40 {
41 std::sort(begin(), end());
42 }
43
45 {
46 uint32 Seed = 0;
47 for (const auto& Elem : Array)
48 Seed ^= GetTypeHash(Elem) + 0x9e3779b9 + (Seed << 6) + (Seed >> 2);
49 return Seed;
50 }
51};
52
53namespace std
54{
55template<>
56struct hash<TArray<int32>>
57{
58 std::size_t operator()(const TArray<int32>& Array) const
59 {
60 size_t Seed = 0;
61 for (const auto& Elem : Array)
62 Seed ^= std::hash<int>()(Elem) + 0x9e3779b9 + (Seed << 6) + (Seed >> 2);
63 return Seed;
64 }
65};
66}
67#endif
uint32 GetTypeHash(const TArray< InElementType, InAllocatorType > &A)
Definition Array.h:4151
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint32 Size
Definition VulkanMemory.cpp:4034
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT RangedForIteratorType end()
Definition Array.h:3391
void SetNum(SizeType NewNum, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2308
UE_NODEBUG UE_FORCEINLINE_HINT RangedForIteratorType begin()
Definition Array.h:3389
friend class TArray
Array that allocates elements on the heap.
Definition Array.h:672
TArray & operator=(std::initializer_list< InElementType > InitList)
Definition Array.h:785
UE_NODEBUG void Sort()
Definition Array.h:3418
int
Definition TestServer.py:515