std::mapの使い方
戻る
#include <stdio.h>
#include <map>
/**
* $Id: std-map-test.html,v 1.1 2009/06/22 16:12:27 kishi Exp kishi $
*/
void
using_map ()
{
typedef std::pair < int, double >thePair;
std::map < int, double >myMap;
myMap.insert (thePair (21, 872334.9));
myMap.insert (thePair (35, 8.32));
myMap.insert (thePair (1000, 892234.09));
std::map < int, double >::iterator cIter = myMap.find (1000);
if (cIter != myMap.end ()) {
printf ("%d, %f\n", (*cIter).first, (*cIter).second);
}
}
int
main ()
{
using_map ();
return 0;
}
戻る