///////////////////////////////////////////////////////////////////////////////
//STL( map )
//map의 index에 의해서 정렬되어 값이 출력됨.
//index키값을 이용해 신속하게 값을 찾을 수 있다.
//중복된 index를 허용하지 않는다.
//정력컨테이너 : 키값을 이용해서 데이터를 신속하게 찾을 수 있다.
///////////////////////////////////////////////////////////////////////////////

#include <iostream>
#include <map>

 

using namespace std;

 

void main()
{
    map<int, char*> map1;
    map<int, char*>::iterator it;

    map1[3] = "yi";
    map1[2] = "ki";
    map1[1] = "ho";

 

    for( it = map1.begin(); it != map1.end(); it++ )

    {
        cout << it->first << it->second << endl;
    }

 

    map1[1] = "wow";
    map1[3] = "hi";

 

    for( it = map1.begin(); it != map1.end(); it++ )

    {
        cout << it->first << it->second << endl;
    }

 

    map1.erase(3);  //index키값을 이용해 쉽게 자료를 삭제할 수도 있다.

   

    for( it = map1.begin(); it != map1.end(); it++ )

    {
        cout << it->first << it->second << endl;
    }
}


+ Recent posts