tommym121
asked on
re-index vector
I am try to reading a set of records from a file to a vector of data structures.
for example
DataSturcture {
string Name;
int ID;
string AlternateName;
}
I like create a index of each member so I don't have to search everytime I try to access them. How would I do that? Is any class in std library or boost can do that?
for example
DataSturcture {
string Name;
int ID;
string AlternateName;
}
I like create a index of each member so I don't have to search everytime I try to access them. How would I do that? Is any class in std library or boost can do that?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. I learn a lot. Thank you again.
ASKER
If I understand what you mean. I should put the data sturcture into map. How can I optimize the retrieve of the record, Sometime I need to use the Name, other time to use the ID or the AlternateName.
I am trying to borrow the same concept in database, i.e. to use each of the field as a key to index so I can simply
Now with you example I can do mapIDTodDataStructure, But I would also like to perform
& mapNameTodDataStructure (Name)
& mapAlternateNameToDataStuc
Do I have to read the file 3 times or a better way to handle this?
Thanks