I've been contemplating a problem and wondering what's the better container for my particular solution.
In this case, I have a group/list/collection/whatever of objects called Entity. Entities have both a 'Name' property and an 'Update()' function. Simple enough.
I expect to have a maximum of 200 entities in any particular group at any time.
I've been wondering whether or not to use a std::map or a std::vector for hanging on to these Entity's. I want to be able to retrieve an Entity via its name. With map, this is very easy using the [] operator. With vector, I have to do the comarison manually but ultimately it's trivial.
My concern comes with iterating through the entire list of Entity objects to call their update functions. It's simple enough to iterate through each container type but would it be faster to use a vector and iterate using a for loop (e.g., for(int i = 0; i < vector.size(); i++)) or is it ultimately about the same speed using an iterator for map? I could just build a wrapper class to abstract all of that and just test both solutions but I thought I'd ask first.