How do I iterate through a UDataTable?

If you are simply iterating trough all rows, I believe the following code is simpler and faster:

UDataTable *DataTable;
struct FMyStruct : public FTableRowBase
{
UPROPERTY()… etc
}

for (auto& data : DataTable->GetRowMap())
{
FName name = data.Key;
FMyStruct* MyStruct = reinterpret_cast<FMyStruct*>(data.Value);

// do something with name. and MyStruct->

}

Since internally it is simply a TMAP of fname and a generic pointer.
It is interesting to see that they used a uint8* instead of a void* to indicate a generic pointer.

4 Likes