돌고래 홈페이지
ID:
PW:


  운영자(2022-03-08 18:54:02, Hit : 597, Vote : 297
 TArray 관련

빠른 TArray 복사
https://ikrima.dev/ue4guide/networking/network-replication/fast-tarray-replication/

구조체 소팅
        list.Sort([](const FRank& A, const FRank& B) {
                return A.ranking < B.ranking;
        });

구조체 검색
        FString UserNickName = TEXT("333");
        int32 Index = list.IndexOfByPredicate([UserNickName](const FRank& Rank) {
                return (Rank.userNickName == UserNickName);
        });


--------------------------------------------------------------------------------

USTRUCT(BlueprintType)
struct FMyStruct
{
        GENERATED_BODY()
public:
        FMyStruct();
        FMyStruct(FString& _Name, int _id);
        ~FMyStruct();
        UPROPERTY()
        FString Name;
        UPROPERTY()
        int id = 0;
};

FMyStruct::FMyStruct()
{
}

FMyStruct::FMyStruct(FString& _Name, int _id)
{
        Name = _Name;
        id = _id;
}

FMyStruct::~FMyStruct()
{
}

void AddArray(TArray<FMyStruct>& MyList, const FString& Name, int Id)
{
        FMyStruct My;
        My.Name = Name;
        My.id = Id;
        MyList.Add(My);
}

---------------------------------------------------

        TArray<FMyStruct> MyList;
        
        AddArray(MyList, TEXT("bbb"), 2);
        AddArray(MyList, TEXT("ccc"), 3);
        AddArray(MyList, TEXT("aaa"), 1);
        
        MyList.StableSort([](const FMyStruct& A, const FMyStruct& B) {
                return A.id < B.id;
        });
        //id : 1, 2, 3 순서로 정렬

        MyList.StableSort([](const FMyStruct& A, const FMyStruct& B) {
                return A.id > B.id;
        });
        //id : 3, 2, 1 순서로 정렬




언리얼 동영상 재생
강좌

Copyright 1999-2022 Zeroboard / skin by zero