揮発性のメモ2

http://d.hatena.ne.jp/iww/

ソートされないmultimap

もうmapでもなんでもない

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(){
    typedef pair<string,int> P;
    typedef vector<P> M;
    typedef M::iterator MIT;

    M list;
    list.push_back( P( "hoge", 1 ) );
    list.push_back( P( "piyo", 2 ) );
    list.push_back( P( "fuga", 3 ) );
    list.push_back( P( "hoge", 4 ) );
    list.push_back( P( "piyo", 5 ) );
    list.push_back( P( "hoge", 6 ) );

    cout << "■全部" << endl;
    for( MIT it=list.begin(); it!=list.end(); ++it ){
        cout << it->first << ':' << it->second << endl;
    }

    return 0;
}