Unreal Engine C++: TMap doc sheet
UE TMap documentation, reference sheet, cheat sheet - 11/2022 - #Unreal
Cheat sheet to unreal's TMap and equivalence with std::map.
Basic
#include "Containers/Map.h"
std::map<K, T> | TMap<K, T> | |
---|---|---|
Insert a new unique element | map[key] = value | .Add(key, value) |
Find by key | std::map it = map.find( key ); // Test if found: it != map.end(); |
T* value = map.Find(key) // Test if found: value != nullptr; |
Find or add a default value. i.e. value == T() if key does not exists. |
T& value = map[ key ]; | T& value = map.FindOrAdd(key) |
Number of elements | .size() | .Num() |
Check (size == 0) / (Num == 0) |
.empty() | .IsEmpty() |
Set number of elements to 0 |
.clear() | .Empty() // Keep allocated memory .Reset() |
Pre-allocate memory | None | .Reserve(int size) |
Advanced
std::map<K, T> | TMap<K, T> | |
---|---|---|
Remove element which matches 'key' | .erase(key) | .Remove(key) |
Links
TMap<> API referenceNo comments