2,646行もあるUE4のTArrayのヒミツ

Isoparametric
Dec 18, 2017 · 17 min read

注意書き

メモリ戦略

 [EnginePath]/Engine/Source/Runtime/Core/Public/Containers/Array.h

DefaultCalculateSlackGrowはどのような戦略をとるか?

// Allocate slack for the array proportional to its size.
Grow = SIZE_T(NumElements) + 3 * SIZE_T(NumElements) / 8 + 16;
Retval = FMemory::QuantizeSize(Grow * BytesPerElement, Alignment) / BytesPerElement;

コンストラクタ

FORCEINLINE TArray(const TArray& Other, int32 ExtraSlack)

デストラクタ

各種操作

検索

TArray<int>* IntArray1 = new TArray<int>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10});int32 Index = IntArray1->FindLastByPredicate([](const int& Value){ return Value == 5; });

特殊な追加/挿入/削除

通常の追加/挿入/削除

特殊な操作

クラスを指定した検索

ソート

ヒープ化

最後に

Isoparametric

Written by

Game technical director.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade