I want to make a data structure for accessing strings by two ways:
- Access by ID
- Access by name
My first idea is using two maps for each method but it leads to duplication of data:
QMap<int, QString> accessById;
QMap<QString, QString> accessByName;
I’m searching for a better way, something like this:
QMap<QPair<int, QString>, QString> multiAccess;
but it can not help me (at least I don’t know how to do it), because searching in a map needs to know ID and name together. How can I define a well structure of Qt classes to achive my goal?
No external libraries, but Qt
How about:
You access by id and create a map for names and ids. Then you can access by name with