다음을 통해 공유


hash_multimap::insert

[!참고]

이 API는 사용되지 않습니다.대신 unordered_multimap Class.

요소 또는 요소의 범위는 hash_multimap에 삽입합니다.

iterator insert(
   const value_type& _Val
);
iterator insert(
   const_iterator _Where,
   const value_type& _Val
);
template<class InputIterator> 
   void insert(
      InputIterator _First,
      InputIterator _Last
);
template<class ValTy>
    iterator insert(
        ValTy&& _Val
);
template<class ValTy>
    iterator insert(
        const_iterator _Where,
        ValTy&& _Val
);

매개 변수

Parameter

설명

_Val

Hash_multimap에는 hash_multimap 요소 또는 더 일반적으로 키 변환과 정렬 된 요소가 이미 포함 되어 있지 않으면 삽입할 요소의 값입니다.

_Where

올바른 삽입 지점에 대 한 검색을 시작 하는 곳에 대 한 힌트입니다.

_First

지도를 복사 하는 첫 번째 요소의 위치입니다.

_Last

위치 지도를 복사 하는 마지막 요소입니다.

반환 값

처음 두 삽입 멤버 함수는 새 요소가 삽입 된 위치를 가리키는 반복기를 반환 합니다.

마지막 두 삽입 멤버 함수 동작 처음 두와 같은 이동 삽입 된 값을 생성 하는 것을 제외 하 고.

설명

Value_type 정렬 된 쌍의 키 값과 같은 첫 번째 구성 요소 및 요소의 데이터 값과 같은 두 번째 구성 요소 값은 요소의 수 있도록 한 쌍의 요소입니다.

삽입 하면 발생할 수 있습니다 힌트 버전에 삽입 로그 시간 대신 amortized 상수 시간에 바로 삽입 지점 다음에 오는 _Where.

셋째 멤버 함수 요소 값의 시퀀스의 반복기 범위에 의해 주소가 지정 된 각 요소에 해당 하는 맵에 삽입 [_First, _Last) 지정 된 집합입니다.

예제

// hash_multimap_insert.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>
#include <string>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int>::iterator hm1_pIter, hm2_pIter;

   hash_multimap <int, int> hm1, hm2;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 1, 10 ) );
   hm1.insert ( Int_Pair ( 2, 20 ) );
   hm1.insert ( Int_Pair ( 3, 30 ) );

   cout << "The original key values of hm1 =";
   for ( hm1_pIter = hm1.begin( ); hm1_pIter != hm1.end( );
      hm1_pIter++ )
      cout << " " << hm1_pIter -> first;
   cout << "." << endl;

   cout << "The original mapped values of hm1 =";
   for ( hm1_pIter = hm1.begin( ); hm1_pIter != hm1.end( ); 
      hm1_pIter++ )
      cout << " " << hm1_pIter -> second;
   cout << "." << endl;

   hm1.insert ( Int_Pair ( 1, 10 ) );

   // The hint version of insert
   hm1.insert( --hm1.end( ), Int_Pair ( 4, 40 )  );

   cout << "After the insertions, the key values of hm1 =";
   for ( hm1_pIter = hm1.begin( ); hm1_pIter != hm1.end( ); 
      hm1_pIter++ )
      cout << " " << hm1_pIter -> first;
   cout << "," << endl;

   cout << " and the mapped values of hm1 =";
   for ( hm1_pIter = hm1.begin( ); hm1_pIter != hm1.end( ); 
      hm1_pIter++ )
      cout << " " << hm1_pIter -> second;
   cout << "." << endl;

   hm2.insert ( Int_Pair ( 10, 100 ) );

   // The templatized version inserting a range
   hm2.insert( ++hm1.begin( ), --hm1.end( ) );

   cout << "After the insertions, the key values of hm2 =";
   for ( hm2_pIter = hm2.begin( ); hm2_pIter != hm2.end( ); 
      hm2_pIter++ )
      cout << " " << hm2_pIter -> first;
   cout << "," << endl;

   cout << " and the mapped values of hm2 =";
   for ( hm2_pIter = hm2.begin( ); hm2_pIter != hm2.end( ); 
      hm2_pIter++ )
      cout << " " << hm2_pIter -> second;
   cout << "." << endl;

    // The templatized versions move constructing elements
    hash_multimap<int, string> hm3, hm4;
    pair<int, string> is1(1, "a"), is2(2, "b");

    hm3.insert(move(is1));
    cout << "After the move insertion, hm3 contains:" << endl
      << " " << hm3.begin()->first
      << " => " << hm3.begin()->second
      << endl;

    hm4.insert(hm4.begin(), move(is2));
    cout << "After the move insertion, hm4 contains:" << endl
      << " " << hm4.begin()->first
      << " => " << hm4.begin()->second
      << endl;
}
  
  
  
  
  

요구 사항

헤더: <hash_map>

네임 스페이스: stdext

참고 항목

참조

hash_multimap Class

표준 템플릿 라이브러리