I need a way to access a value by passing in any key that the value could have. For example, a player object that can be accessed by either their ip address or name?
To illustrate.
Player1 has ["a", "1.2.3.4"]
Player2 has ["b", "3.4.5.6"]
Player3 has ["c", "2.2.9.3"]
So, to access Player2 I could use players["b"]
, or players["3.4.5.6"]
Should I just iterate over a vector for that? But I plan to have anywhere around 100 elements, so would a tree-like container be better than an array list?
Could you use std::multimap
for that? Or even in std::map
?
Aucun commentaire:
Enregistrer un commentaire