60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "WingServer.h"
|
|
#include "WingBasics.h"
|
|
#include "Containers/BitArray.h"
|
|
#include "Containers/SparseArray.h"
|
|
#include "Test_TMaps.generated.h"
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------
|
|
|
|
UCLASS()
|
|
class UWing_Test_TMaps : public UWingHandler
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
virtual void Register() override
|
|
{
|
|
UWingServer::AddHandler(this,
|
|
TEXT("Constructs a small TMap, TBitArray, and TSparseArray so that "
|
|
"a developer can set a breakpoint and inspect them with the "
|
|
"lldb data formatters."));
|
|
}
|
|
|
|
virtual void Handle() override
|
|
{
|
|
TMap<int32, FString> Map;
|
|
Map.Add(1, TEXT("one"));
|
|
Map.Add(2, TEXT("two"));
|
|
Map.Add(3, TEXT("three"));
|
|
Map.Add(42, TEXT("forty-two"));
|
|
|
|
TBitArray<> Bits;
|
|
Bits.Add(true);
|
|
Bits.Add(false);
|
|
Bits.Add(true);
|
|
Bits.Add(true);
|
|
Bits.Add(false);
|
|
|
|
// Add a few entries, then remove a middle one so the live set is
|
|
// non-contiguous. Exercises the sparse-array formatter against a hole.
|
|
TSparseArray<FString> Sparse;
|
|
Sparse.Add(TEXT("alpha"));
|
|
int32 BetaIdx = Sparse.Add(TEXT("beta"));
|
|
Sparse.Add(TEXT("gamma"));
|
|
Sparse.Add(TEXT("delta"));
|
|
Sparse.RemoveAt(BetaIdx);
|
|
|
|
TTuple<int32, FString, float, bool, FName> Tuple(1, TEXT("hello"), 3.14f, true, FName("world"));
|
|
|
|
// Set a breakpoint on the following line to inspect Map, Bits, and Sparse.
|
|
WingOut::Stdout.Printf(TEXT("Test_TMaps: Map has %d entries, Bits has %d bits, Sparse has %d entries.\n"),
|
|
Map.Num(), Bits.Num(), Sparse.Num());
|
|
}
|
|
};
|