suppose you need to implement container of a T
items, which its value could be retrieved by numeric index (which is random access) and by name (as string).
which one is better in term of performance of common operation such as retrieval, adding, and removing the items:
(in this case retrieval by index need to be implemented by walking the map)
std::map<std::string,T> container;
or (fast random access by index, but need walking for retrieval by name)
std::vector<std::pair<std::string,T>> container;
or by providing two separate container (fast retrieval, but slower adding/removal operation)
std::vector<T> byIndexContainer;
std::map<std::string,T> byNameContainer;
or you can suggest other data structure that is better?