i have somthing like
now i want to store many instances of this in a container.Code:class MyClass { std::string id; /* other members */ };
because i want to be able to do a quick lookup based on the id i would chose either std::map or std::set (or the hashed versions).
now,
actually i want to be able to map ids to the MyClass-instances - thus map,
on the otherhand the MyClass needs its id internally so somthing like std::map<std::string, MyClass> would duplicate the id - and thats not good - since the id is constant anyway and it would be just a waste of memory.
so i guess i want a std::set<MyClass>.
but i need to lookup the MyClass instances by id - and of course by binary search.
so whats the best way to do this?
i mean: do i have to write my own binsearch function - or is there some template part of the stl? i need an iterator as a search result.