// MyStl.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <map>
#include <vector>
#include <string>
#include <utility>
#include <iostream>
#include "MyAlloc.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
happyever ::InitShm();
multimap<string,int,less<string>,happyever ::MyAlloc<string> > m;
m.insert(make_pair(string("Harry"), 32));
m.insert(make_pair(string("Mary"), 59));
m.insert(make_pair(string("Roger"), 18));
m.insert(make_pair(string("Nancy"), 37));
m.insert(make_pair(string("Mary"), 23));
typedef multimap<string,int,less<string>,happyever ::MyAlloc<string> >::iterator Iter;
for (Iter p = m.begin(); p != m.end(); p++)
{
cout << p->first << "," << p->second << endl;
}
Iter p = m.find("Harry");
m.erase(p);
/*p = m.find("Harry");
cout << "Harry is: " << p->second << "." << endl;*/ for (Iter p = m.begin(); p != m.end(); p++)
{
cout << p->first << "," << p->second << endl;
}
return 0;
}
|