Sunday, 15 September 2013

c++ - Find on list of map -


Hello I'm working on a project and I'm starting in C ++

I have a list of maps

  list & lt; Maps & lt; Int, double> & Gt; Voisin;  

And I would like to know whether it is possible to check whether the element exists in my map or not. It's a C # code and can you tell me how to do it in C ++.

  var res = voisin [a]. Search (map  x)  

thanks

Take a look at it

It should clean things.

  // map :: find #include & lt; Iostream & gt; # Include & lt; Map & gt; Int main () {std :: map & lt; Char, int & gt; Mymap; Std :: map & lt; Char, int & gt; :: Iterator; Mymap ['one'] = 50; Mymap ['b'] = 100; Mymap ['c'] = 150; Mymap ['d'] = 200; This mymap.find ('b') =; Mymap.erase (this); Mymap.erase (mymap.find ('D')); // print content: std :: cout & lt; & Lt; "Element in mammal:" & lt; & Lt; '\ N'; Std :: cout & lt; & Lt; "A = & gt;" & Lt; & Lt; Mymap.find ('a') - & gt; Second & lt; & Lt; '\ N'; Std :: cout & lt; & Lt; "C => & Lt; & Lt; Mymap.find ('c') - & gt; Second & lt; & Lt; '\ N'; Return 0; }  

Output: element in mymap: a => 50c => 150


No comments:

Post a Comment