finding element in map with list c++ -
I have a conviction with an integer (x) and a list (list).
std :: map & lt; Integer, std :: from the list & lt; Integer & gt; & Gt; My_map; My list 1 contains 100,200,300 elements and I see it in integer 1 Elements in mylist2 are 99,199,299 and I see it in integer 2
My_map.insert (pair & lt; int, std :: list & lt; int & gt; & gt; (1, mylist1)); My_map.insert (pair & lt; int, std :: list & lt; int & gt; & gt; (2, mylist2));
Now one element tells 200, how can I return value 1 (saying that element is related to the 200 list which is mapped to 1 element integer? < / P>
You should use the elements of the lists as keys and as an integer value. :
Std :: multimap & lt; int, int> my_map; my_map.insert (std :: make_pair (100, 1)); my_map.insert (std :: make_pair 200, 1)); my_map.insert (std :: make_pair 300, 1)); My_map.insert (std :: make_pair (99, 2)); My_map.insert (std :: make_pair (199, 2)); My_map.insert (std :: make_pair (2 9, 2));
Then only std :: multimap & lt; Int, int & gt; :: equal_range
function
Comments
Post a Comment