04.UE4学习总结.Blueprints to C++.TArray常用方法

 

 

TArray<FVector> Array;

    Array.Add(FVector::ZeroVector);

    Array.Insert(FVector::ZeroVector, 1);

    VecArray.Append(Array);


    const int32 NumElements = VecArray.Num();

    const int32 ArrayLastIndex = VecArray.Num() - 1;

    FVector& Element = VecArray[0];

    if (VecArray.Contains(FVector::ZeroVector))
    {
    }

    const int32 Idx = VecArray.Find(FVector::ZeroVector);
    if (Idx != INDEX_NONE)
    {
    }

    int32 Index;
    if (VecArray.Find(FVector::ZeroVector, Index))
    {
    }

    VecArray.Remove(FVector::ZeroVector);

    VecArray.RemoveAt(2);

    VecArray.Empty();


    const int32 Num = VecArray.Num();

    for (int32 i = 0; i < Num; i++)
    {
        FVector& Vec = VecArray[i];
        float Val = Vec.X;
    }

    const int32 LastIndex = VecArray.Num() - 1;
    for (int32 i = 0; i < LastIndex; i++)
    {
        FVector& Vec = VecArray[i];
        float Val = Vec.X;
    }

    for (FVector& Vec: VecArray)
    {
        float Val = Vec.X;
    }

    for (auto& vec:VecArray)
    {
        float Val = vec.X;
    }


    for (auto It = VecArray.CreateIterator(); It; ++It)
    {
        FVector& Vec = *It;
        float Val = Vec.X;
        
    }

    for (auto It = VecArray.CreateIterator(); It; ++It)
    {
        const FVector& Vec = *It;
        float Val = Vec.X;
    }
    

 

posted @ 2022-02-13 00:52  底层逻辑  阅读(262)  评论(0)    收藏  举报