What kind of collection method would store a pair (key and value) where the key isn't unique (which technically doesn't make it a key I think)?
Somewhere in my program I have:
typedef struct
{
int nKey;
string strFormType;
} KeyPair;
Then I'll store objects in a vector using this struct.
vector<KeyPair> vKeyList;
KeyPair MenuOne;
MenuOne.nKey = 1;
MenuOne.strFormType = "Window";
vKeyList.push_back(MenuOne);
MenuOne.nKey = 0;
MenuOne.strFormType = "Window2";
vKeyList.push_back(MenuOne);
MenuOne.nKey = 1;
MenuOne.strFormType = "WindowC";
vKeyList.push_back(MenuOne);
This is basically how I want to store objects in the vector. My problem is, If I'm to store like a hundred KeyPairs, I should be doing it in a loop and just read off the KeyPairs from a storage then push_back it the the vector.
What if I have to store these KeyPairs:
KEY WINDOW
1 Window
0 Window2
1 WindowC
3 Windowfoo
1 Window
and so on...
I couldn't store it in a map because you have to have a unique key. The keys of the KeyPairs I have aren't unique. Any suggestion?
multimap<>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With