I am extending an already existing C++ code. One of the class members is of type vector of another class objects:
class Road
{
....
vector<Link*> links; //Link is just another class
}
The other modules use this class and its member through a lot of sequence iterators. Now, while extending the code, I need to add a member to Link class called linkID, and use this linkID to find/access my "Link" objects.
Problem: I am not going to search for a Link object(using LinkID) in the vector by iterating through the millions of items, just to find a specific Link object. The best solution is "map"! right?
....
map<linkID,*link> links
....
lnk=links[linkID]
.........
But the problem is that i cannot modify the current source code except very minor modifications lik adding linkID etc.
So my obvious question is: is it possible to use map in place of vector(any how). In the other words, I want to create a map, fill it up, and later treat it as a vector. possible? Thank you for your comments