다음을 통해 공유


hash_multiset::insert

[!참고]

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

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

iterator insert(
   const value_type& _Val
);
iterator insert(
   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_multiset에는 hash_multiset 요소 또는 더 일반적으로 키 변환과 정렬 된 요소가 이미 포함 되어 있지 않으면 삽입할 요소의 값입니다.

_Where

올바른 삽입 지점에 대 한 검색을 시작 하는 곳입니다.(삽입 발생할 수 있습니다 로그 시간 대신 amortized 상수 시간에 바로 삽입 지점 다음에 오는 경우 _Where.)

_First

첫 번째 요소는 hash_multiset에서 복사할 위치를 지정 합니다.

_Last

위치는 hash_multiset에서 복사 하는 마지막 요소입니다.

반환 값

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

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

설명

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

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

예제

// hash_multiset_insert.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multiset <int>::iterator hms1_pIter, hms2_pIter;

   hash_multiset <int, hash_compare <int, less<int> > > hms1, hms2;
   hms1.insert( 10 );
   hms1.insert( 20 );
   hms1.insert( 30 );
   hms1.insert( 40 );

   cout << "The original hms1 =";
   for ( hms1_pIter = hms1.begin( ); hms1_pIter != hms1.end( );
         hms1_pIter++ )
      cout << " " << *hms1_pIter;
   cout << "." << endl;


   hms1.insert( 20 );
   hms1.insert( --hms1.end( ), 50 );

   cout << "After the insertions, hms1 =";
   for ( hms1_pIter = hms1.begin( ); hms1_pIter != hms1.end( );
         hms1_pIter++ )
      cout << " " << *hms1_pIter;
   cout << "." << endl;

   hms2.insert( 100 );
   hms2.insert( ++hms1.begin( ), --hms1.end( ) );

   cout << "hms2 =";
   for ( hms2_pIter = hms2.begin( ); hms2_pIter != hms2.end( );
         hms2_pIter++ )
      cout << " " << *hms2_pIter;
   cout << "." << endl;

   // move construct an element
   hash_multiset<string> hms3, hms4;
   string str1("a"), str2("b");

   hms3.insert(move(str1));
   cout << "After the move insertion, hms3 contains "
      << *hms3.begin() << "." << endl;

   hms4.insert(hms4.begin(), move(str1));
   cout << "After the move insertion, hms4 contains "
      << *hms4.begin() << "." << endl;
}
  
  
  
  
  

요구 사항

헤더: <hash_set>

네임 스페이스: stdext

참고 항목

참조

hash_multiset Class

표준 템플릿 라이브러리