TMapMyMap; MyMap.Add(0, "Zero"); MyMap.Add(1, "One"); MyMap.Add(2, "Two"); FString& ValueRef = MyMap.FindRef(1); // ValueRef now references the string "One"
TMapIn this example, we create a new TMap that maps const FName objects to floats. We add two entries to the map using FName literals. We then create a const FName object named Key and initialize it with the value "Bar". We call Find on the map with Key and store the returned pointer in ValuePtr. The pointer will be null if the key is not found. If ValuePtr is not null, we dereference it to get the float value associated with the key. Package library: Unreal Engine APIMyMap; MyMap.Add(FName(TEXT("Foo")), 1.0f); MyMap.Add(FName(TEXT("Bar")), 2.0f); const FName Key(TEXT("Bar")); const float* ValuePtr = MyMap.Find(Key); if (ValuePtr != nullptr) { float Value = *ValuePtr; // Do something with the value }