다음을 통해 공유


list::insert (STL/CLR)

지정 된 위치에 요소를 추가합니다.

    iterator insert(iterator where, value_type val);
    void insert(iterator where, size_type count, value_type val);
    template<typename InIt>
        void insert(iterator where, InIt first, InIt last);
    void insert(iterator where,
        System::Collections::Generic::IEnumerable<Value>^ right);

매개 변수

  • count
    삽입할 요소 수입니다.

  • 첫 번째
    삽입할 범위의 시작 부분입니다.

  • last
    삽입 범위 끝입니다.

  • right
    삽입할 열거형입니다.

  • val 함수
    삽입할 요소의 값입니다.

  • where
    하기 전에 삽입할 컨테이너에서 위치입니다.

설명

각 멤버의가 가리키는 요소 앞에 삽입 작동 where 제어 되는 시퀀스의 시퀀스 나머지 피연산자를 통해 지정 합니다.

멤버 함수는 첫 번째 요소 값을 삽입 합니다. val 및 새로 삽입 된 요소를 지정 하는 반복기를 반환 합니다.이 단일 요소는 반복기가 지정 하는 장소 앞에 삽입할 수 있습니다.

두 번째 멤버 함수는 반복 된 삽입 count 요소 값의 val.이 모든 복사본이 같은 값에는 0 개 이상의 연속 요소를 삽입할 수 있습니다.

If InIt is an integer type, the third member function behaves the same as insert(where, (size_type)first, (value_type)last).Otherwise, it inserts the sequence [first, last).다른 시퀀스에서 복사 된 0 개 이상의 연속 요소를 삽입 하려면 사용 합니다.

순서 지정을 삽입 하는 네 번째 멤버 함수는 right.이 열거형에서 설명 하는 시퀀스를 삽입할 수 있습니다.

단일 요소를 삽입 하는 경우 매수 요소 삽입 지점과 떨어진 시퀀스 끝 사이의 요소 수가 선형입니다.(두 시퀀스의 끝에 하나 이상의 요소를 삽입 하는 경우 양도인이 요소 발생) 경우 InIt 입력된 반복기입니다 세 번째 멤버 함수 효과적으로 시퀀스의 각 요소에 대해 하나의 삽입을 수행 합니다.그렇지 않으면 삽입할 때 N 요소를 요소 매수 되지에서 선형 N 플러스 삽입점에서 떨어진 시퀀스 끝 사이의 요소 수입니다.

예제

// cliext_list_insert.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(); 
 
// insert a single value using iterator 
    cliext::list<wchar_t>::iterator it = c1.begin(); 
    System::Console::WriteLine("insert(begin()+1, L'x') = {0}", 
        *c1.insert(++it, L'x')); 
    for each (wchar_t elem in c1) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
// insert a repetition of values 
    cliext::list<wchar_t> c2; 
    c2.insert(c2.begin(), 2, L'y'); 
    for each (wchar_t elem in c2) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
// insert an iterator range 
    it = c1.end(); 
    c2.insert(c2.end(), c1.begin(), --it); 
    for each (wchar_t elem in c2) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
// insert an enumeration 
    c2.insert(c2.begin(),   // NOTE: cast is not needed 
        (System::Collections::Generic::IEnumerable<wchar_t>^)%c1); 
    for each (wchar_t elem in c2) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
// insert a single value using index 
    it = c2.begin(); 
    ++it, ++it, ++it; 
    c2.insert(it, L'z'); 
    for each (wchar_t elem in c2) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
    return (0); 
    } 
 
  

요구 사항

헤더: < cliext/목록 >

네임 스페이스: cliext

참고 항목

참조

list (STL/CLR)

list::assign (STL/CLR)