Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can two Key Values be same in a Map

I have defined a Map

boost::unordered_map<"std::string,std::string">m_mapABC ;

And I Store values in it Like m_mapABC[strValue1]=strValue2;

And Assume that i store 10 entries to the map.In that case can the same Key Value be used to store 10 different Values..or will it be over written every time...I guess it would.
In that case using std::pair would help i guess.

std::map<"std::string, std::pair<"std::string", bool>>myMap2

std::pair can have 2 Key Values Equal(I guess I am Right)...What will be the bool value in each case,will it be TRUE in the first case and FALSE the second time or vice-versa?.

I also heard about std::tuple or boost::tuple where a single Key can be used to Store Different Values.

I am not very clear about how to iterate through them...i need help

like image 596
payyans4u Avatar asked Dec 04 '22 03:12

payyans4u


1 Answers

You may want multimap instead of map.

like image 161
nhahtdh Avatar answered Dec 13 '22 22:12

nhahtdh