You might use a map where you need a key and value pair. This is similar to the Dictionary in C#. Say you have a character with different armor types (helmet, chest, legs, arms). Those can be your keys. Then for the values you can have the actual armor assets. So if your character is wearing no helmet, the value of key “helmet” is null. The character picks up a bicycle helmet and puts it on, so now the value of “helmet” will be set to the bicycle helmet blueprint actor. That’s just an example, there are many reasons for wanting a map. Really it’s any time you have two values that must go together.
You would use a Set in cases where you want to use an array but the order doesn’t matter and you won’t need duplicate entries. Sets are supposedly faster to index than arrays but I don’t know the actual speed difference. I doubt it’s very much and in most situations won’t make any perceptible difference.
The thing about these containers is that they are unordered. While an array is guaranteed to have a numbered structure, items in a map or set do not, so you can’t grab an item at a specific index since an ordered table of indices does not exist. This is why they are faster to grab from at a low level, but something that may make them undesirable in some workflows.
If you want an ordered version of the Map, a “type” doesn’t exist but you can make an array of structures with the types you need as a workaround.
So in short:
-Sets are basically arrays with only unique entries and no guaranteed order but are faster on a low level than arrays, good for specific speed-critical situations where order and duplicate entries are not necessary.
-Maps are kind of like an array of structures but only take two types at once and, like sets, have no guaranteed order and keys must be unique (values can be duplicated across multiple keys). Again, they are faster on a low level than an array of structures and take less time to set up (as a structure need not be created first).