你可能想要这样的东西:
#include <map>
#include <vector>
#include <assert.h>
using namespace std;
int main()
{
// Declare initialized polyMap
map<unsigned int, vector<vector<unsigned int>> > polyMap
{
{ 11,
{
{ 1,2 }, { 3,4 }
}
},
{ 22,
{
{ 5,6 }, { 7,8 }
}
}
};
// add another element dynamically
polyMap.insert(pair<int, vector<vector<unsigned int>>>(
{ 33,
{
{ 9, 10 },{ 11, 12 }
}
}
));
// check expected outcome for some values
assert(polyMap[11][0][0] == 1);
assert(polyMap[11][0][1] == 2);
assert(polyMap[22][1][1] == 8);
assert(polyMap[33][1][1] == 12);
}