///////////////////////////////////////////////////////////////////////////////
//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;
}
}
'Programming > STL' 카테고리의 다른 글
list (0) | 2010.11.16 |
---|---|
set - 랜덤하게 값을 집어 넣으면서 중복값을 빼고 소팅 (0) | 2010.11.16 |
stack (0) | 2010.11.16 |
vector - 가변길이의 순차적인 배열에 대한 임의의 접근 가능 (0) | 2010.11.16 |