C++ C++;集合:如何创建类似地图的结构

C++ C++;集合:如何创建类似地图的结构,c++,data-structures,collections,vector,maps,C++,Data Structures,Collections,Vector,Maps,什么样的收集方法会在密钥不唯一的情况下存储一对(密钥和值)(我认为从技术上讲,它不是密钥) 在我的课程中,我有: typedef struct { int nKey; string strFormType; } KeyPair; 然后我将使用此结构将对象存储在向量中 vector<KeyPair> vKeyList; KeyPair MenuOne; MenuOne.nKey = 1; MenuOne.strFormType = "Window"; vK

什么样的收集方法会在密钥不唯一的情况下存储一对(密钥和值)(我认为从技术上讲,它不是密钥)

在我的课程中,我有:

typedef struct 
{
    int nKey;
    string strFormType;
} KeyPair;
然后我将使用此结构将对象存储在向量中

 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);      

我无法将其存储在地图中,因为您必须具有唯一的密钥。我拥有的钥匙对的钥匙不是唯一的。有什么建议吗

按照Ignacio Vazquez Abrams的建议使用
多重映射
,或者保持向量排序并使用
下限
 KEY WINDOW
 1   Window 
 0   Window2
 1   WindowC
 3   Windowfoo
 1   Window
 and so on...