multimap::erase (STL/CLR)
지정된 위치에 있는 요소를 제거합니다.
iterator erase(iterator where);
iterator erase(iterator first, iterator last);
bool erase(key_type key)
매개 변수
첫 번째
지울 범위의 시작 부분입니다.키
지울 키 값입니다.last
지울 범위 끝입니다.where
지울 요소입니다.
설명
가 가리키는 제어 되는 시퀀스의 요소를 제거 하는 첫 번째 멤버 함수 where를 클릭 하 고 요소 제거를 넘어 남은 첫 번째 요소를 지정 하는 반복기를 반환 합니다. 또는 multimap::end (STL/CLR)() 이러한 요소가 있으면.단일 요소를 제거 하려면 사용 합니다.
제어 되는 시퀀스의 요소 범위에서 두 번째 멤버 함수를 제거 [first, last), 제거 된 요소 외에 남은 첫 번째 요소를 지정 하는 반복기를 반환 합니다. 또는 end() 이러한 요소가 존재 하는 경우.0 개 이상의 연속 된 요소를 제거 하려면 사용 합니다.
세 번째 멤버 함수를 가진 키가 동일한 순서 제어 되는 시퀀스의 요소를 제거 하려면 key, 및 제거 된 요소 수를 반환 합니다.제거 하 고 개수는 지정 된 키와 일치 하는 모든 요소를 사용 합니다.
각 요소 지우기 밑의 요소 개수에 비례 제어 되는 시퀀스에 걸립니다.
예제
// cliext_multimap_erase.cpp
// compile with: /clr
#include <cliext/map>
typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
{
cliext::multimap<wchar_t, int> c1;
c1.insert(cliext::multimap<wchar_t, int>::make_value(L'a', 1));
c1.insert(cliext::multimap<wchar_t, int>::make_value(L'b', 2));
c1.insert(cliext::multimap<wchar_t, int>::make_value(L'c', 3));
// display contents " [a 1] [b 2] [c 3]"
for each (cliext::multimap<wchar_t, int>::value_type elem in c1)
System::Console::Write(" [{0} {1}]", elem->first, elem->second);
System::Console::WriteLine();
// erase an element and reinspect
cliext::multimap<wchar_t, int>::iterator it =
c1.erase(c1.begin());
System::Console::WriteLine("erase(begin()) = [{0} {1}]",
it->first, it->second);
// add elements and display " b c d e"
c1.insert(cliext::multimap<wchar_t, int>::make_value(L'd', 4));
c1.insert(cliext::multimap<wchar_t, int>::make_value(L'e', 5));
for each (cliext::multimap<wchar_t, int>::value_type elem in c1)
System::Console::Write(" [{0} {1}]", elem->first, elem->second);
System::Console::WriteLine();
// erase all but end
it = c1.end();
it = c1.erase(c1.begin(), --it);
System::Console::WriteLine("erase(begin(), end()-1) = [{0} {1}]",
it->first, it->second);
System::Console::WriteLine("size() = {0}", c1.size());
// erase end
System::Console::WriteLine("erase(L'x') = {0}", c1.erase(L'x'));
System::Console::WriteLine("erase(L'e') = {0}", c1.erase(L'e'));
return (0);
}
요구 사항
헤더: < cliext/지도 >
네임 스페이스: cliext