list::erase (STL/CLR)
지정된 위치에 있는 요소를 제거합니다.
iterator erase(iterator where);
iterator erase(iterator first, iterator last);
매개 변수
첫 번째
지울 범위의 시작 부분입니다.last
지울 범위 끝입니다.where
지울 요소입니다.
설명
가 가리키는 제어 되는 시퀀스의 요소를 제거 하는 첫 번째 멤버 함수 where.단일 요소를 제거 하려면 사용 합니다.
제어 되는 시퀀스의 요소 범위에서 두 번째 멤버 함수를 제거 [first, last).0 개 이상의 연속 된 요소를 제거 하려면 사용 합니다.
제거 된 요소 외에 남은 첫 번째 요소를 지정 하는 반복기 멤버 함수 모두 반환 또는 list::end (STL/CLR)() 이러한 요소가 존재 하는 경우.
요소 지우기 때 요소 매수 선형에서 지울 끝 사이의 떨어진 최종 시퀀스의 요소 수입니다.(시퀀스의 양쪽 끝에 하나 이상의 요소를 지우는 경우 양도인이 요소 발생)
예제
// cliext_list_erase.cpp
// compile with: /clr
#include <cliext/list>
int main()
{
cliext::list<wchar_t> c1;
c1.push_back(L'a');
c1.push_back(L'b');
c1.push_back(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
// erase an element and reinspect
System::Console::WriteLine("erase(begin()) = {0}",
*c1.erase(c1.begin()));
// add elements and display " b c d e"
c1.push_back(L'd');
c1.push_back(L'e');
for each (wchar_t elem in c1)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
// erase all but end
cliext::list<wchar_t>::iterator it = c1.end();
System::Console::WriteLine("erase(begin(), end()-1) = {0}",
*c1.erase(c1.begin(), --it));
System::Console::WriteLine("size() = {0}", c1.size());
return (0);
}
요구 사항
헤더: < cliext/목록 >
네임 스페이스: cliext