/**
* Adds a raw array of elements to the end of the TArray.
*
* @param Ptr A pointer to an array of elements to add.
* @param Count The number of elements to insert from Ptr.
* @see Add, Insert
*/voidAppend(const ElementType* Ptr, SizeType Count){check(Ptr !=nullptr|| Count ==0);//根据传进来的参数,分配内存不会调用构造函数
SizeType Pos =AddUninitialized(Count);//根据地址和大小,把含有原数据的内存复制到新分配的内存中
ConstructItems<ElementType>(GetData()+ Pos, Ptr, Count);}/**
* Adds a given number of uninitialized elements into the array.
*
* Caution, AddUninitialized() will create elements without calling
* the constructor and this is not appropriate for element types that
* require a constructor to function properly.
*
* @param Count Number of elements to add.
* @returns Number of elements in array before addition.
*/
FORCEINLINE SizeType AddUninitialized(SizeType Count =1){CheckInvariants();checkSlow(Count >=0);const SizeType OldNum = ArrayNum;if((ArrayNum += Count)> ArrayMax){ResizeGrow(OldNum);}return OldNum;}
FORCENOINLINE voidResizeGrow(SizeType OldNum){
ArrayMax = AllocatorInstance.CalculateSlackGrow(ArrayNum, ArrayMax,sizeof(ElementType));
AllocatorInstance.ResizeAllocation(OldNum, ArrayMax,sizeof(ElementType));}voidResizeAllocation(
SizeType PreviousNumElements,
SizeType NumElements,
SIZE_T NumBytesPerElement
){// Avoid calling FMemory::Realloc( nullptr, 0 ) as ANSI C mandates returning a valid pointer which is not what we want.if(Data || NumElements){//checkSlow(((uint64)NumElements*(uint64)ElementTypeInfo.GetSize() < (uint64)INT_MAX));
Data =(FScriptContainerElement*)FMemory::Realloc( Data, NumElements*NumBytesPerElement, Alignment );}}template<typename DestinationElementType,typename SourceElementType,typename SizeType>
FORCEINLINE voidConstructItems(void* Dest,const SourceElementType* Source, SizeType Count){ifconstexpr(TIsBitwiseConstructible<DestinationElementType, SourceElementType>::Value){
FMemory::Memcpy(Dest, Source,sizeof(SourceElementType)* Count);}else{while(Count){new(Dest)DestinationElementType(*Source);++(DestinationElementType*&)Dest;++Source;--Count;}}}