multimap::insert (STL/CLR)
요소를 추가합니다.
iterator insert(value_type val);
iterator insert(iterator where, value_type val);
template<typename InIter>
void insert(InIter first, InIter last);
void insert(System::Collections::Generic::IEnumerable<value_type>^ right);
매개 변수
첫 번째
삽입할 범위의 시작 부분입니다.last
삽입 범위 끝입니다.right
삽입할 열거형입니다.val 함수
삽입할 키 값입니다.where
(힌트에만 해당)를 삽입 하려면 컨테이너에 위치 합니다.
설명
각 멤버 함수는 나머지 피연산자를 통해 지정 된 시퀀스를 삽입 합니다.
멤버 함수는 첫 번째 요소 값을 삽입 합니다. val, 및 새로 삽입 된 요소를 지정 하는 반복기를 반환 합니다.이 단일 요소를 삽입할 수 있습니다.
요소 값을 삽입 하는 두 번째 멤버 함수 val사용 하 여 where (성능 향상을 위해)을 힌트로 새로 삽입 된 요소를 지정 하는 반복기를 반환 합니다.아시다시피 요소에 인접 한 일 수 있는 단일 요소를 삽입 하려면 사용 합니다.
셋째 멤버 함수 시퀀스 삽입 [first, last).다른 시퀀스를 복사 하는 0 개 이상의 요소를 삽입 하려면 사용 합니다.
순서 지정을 삽입 하는 네 번째 멤버 함수는 right.이 열거형에서 설명 하는 시퀀스를 삽입할 수 있습니다.
각 요소 삽입 요소 수의 밑에 비례 제어 되는 시퀀스에 걸립니다.하지만 삽입 amortized 상수 시간에 삽입점에 인접 하는 요소를 지정 하는 힌트를 제공 발생할 수 있습니다.
예제
// cliext_multimap_insert.cpp
// compile with: /clr
#include <cliext/map>
typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
{
Mymultimap c1;
c1.insert(Mymultimap::make_value(L'a', 1));
c1.insert(Mymultimap::make_value(L'b', 2));
c1.insert(Mymultimap::make_value(L'c', 3));
// display contents " [a 1] [b 2] [c 3]"
for each (Mymultimap::value_type elem in c1)
System::Console::Write(" [{0} {1}]", elem->first, elem->second);
System::Console::WriteLine();
// insert a single value, unique and duplicate
Mymultimap::iterator it =
c1.insert(Mymultimap::make_value(L'x', 24));
System::Console::WriteLine("insert([L'x' 24]) = [{0} {1}]",
it->first, it->second);
it = c1.insert(Mymultimap::make_value(L'b', 2));
System::Console::WriteLine("insert([L'b' 2]) = [{0} {1}]",
it->first, it->second);
for each (Mymultimap::value_type elem in c1)
System::Console::Write(" [{0} {1}]", elem->first, elem->second);
System::Console::WriteLine();
// insert a single value with hint
it = c1.insert(c1.begin(), Mymultimap::make_value(L'y', 25));
System::Console::WriteLine("insert(begin(), [L'y' 25]) = [{0} {1}]",
it->first, it->second);
for each (Mymultimap::value_type elem in c1)
System::Console::Write(" [{0} {1}]", elem->first, elem->second);
System::Console::WriteLine();
// insert an iterator range
Mymultimap c2;
it = c1.end();
c2.insert(c1.begin(), --it);
for each (Mymultimap::value_type elem in c2)
System::Console::Write(" [{0} {1}]", elem->first, elem->second);
System::Console::WriteLine();
// insert an enumeration
Mymultimap c3;
c3.insert( // NOTE: cast is not needed
(System::Collections::Generic::
IEnumerable<Mymultimap::value_type>^)%c1);
for each (Mymultimap::value_type elem in c3)
System::Console::Write(" [{0} {1}]", elem->first, elem->second);
System::Console::WriteLine();
return (0);
}
요구 사항
헤더: < cliext/지도 >
네임 스페이스: cliext