다음을 통해 공유


hash_multiset::hash_multiset

[!참고]

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

생성 된 hash_multiset 즉 빈 즉 모든 복사본 또는 일부 다른 부분이 hash_multiset.

hash_multiset( );
explicit hash_multiset(
   const Traits& _Comp
);
hash_multiset(
   const Traits& _Comp,
   const Allocator& _Al
);
hash_multiset(
   const hash_multiset<Key, Traits, Allocator>& _Right
);
template<class InputIterator>
   hash_multiset(
      InputIterator _First,
      InputIterator _Last
   );
template<class InputIterator>
   hash_multiset(
      InputIterator _First,
      InputIterator _Last,
      const Traits& _Comp
   );
template<class InputIterator>
   hash_multiset(
      InputIterator _First,
      InputIterator _Last,
      const Traits& _Comp,
      const Allocator& _Al
   );
hash_multiset(
   hash_multiset&& _Right
};

매개 변수

Parameter

설명

_Al

저장소 할당자 클래스에 사용 될 hash_multiset 개체는 기본적으로 Allocator.

_Comp

종류의 비교 함수 const Traits 의 요소를 정렬 하는 데는 hash_multiset, 기본값은 hash_compare.

_Right

hash_multiset 는 생성 된 hash_multiset 복사본을 수 있습니다.

_First

복사할 요소의 범위에 있는 첫 번째 요소의 위치입니다.

_Last

복사할 요소의 범위를 벗어난 첫 번째 요소의 위치입니다.

설명

메모리 저장소를 관리 하는 할당 기 개체 유형의 모든 생성자 저장 된 hash_multiset 및 나중에 반환할 호출 하 여 hash_multiset::get_allocator.할당자 매개 변수는 클래스 선언 및 전처리 매크로 대체 할당자를 대체 하는 데에 자주 생략 됩니다.

해당 hash_multisets 모든 생성자를 초기화합니다.

모든 생성자 함수 개체의 형식 저장 Traits 주문 들의 키를 설정 하는 데 사용 된 hash_multiset 및 나중에 반환할 호출 하 여 hash_multiset::key_comp.에 대 한 자세한 내용은 Traits 참조 된 hash_multiset Class 항목.

처음 세 명의 생성자가 빈 초기 지정 hash_multiset, 둘째 종류의 비교 함수를 지정 (_Comp) 요소 및 세 번째 순서를 설정 하는 데 사용할 할당자를 지정 하는 명시적으로 입력 (_Al) 데.키워드 explicit 자동 형식 변환을 특정 종류를 표시 하지 않습니다.

네 번째 생성자의 복사본을 지정 된 hash_multiset_Right.

범위는 다음 세 가지 생성자 복사 [_First,_Last)의 한 hash_multiset 의 할당자 클래스 비교를 비교 함수를 지정 하는 명시적인 증가.

마지막 생성기 이동 하 여 hash_multiset_Right.

해시 집합 컨테이너에서 요소의 실제 순서는 해시 함수에서 해시 테이블의 현재 크기 및 순서 지정 함수 다르고 집합 컨테이너, 정렬 함수에 의해 단독으로 결정 된 곳으로 일반적으로 예측할 수는 없습니다.

예제

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

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multiset <int>::iterator hms1_Iter, hms3_Iter, hms4_Iter,
      hms5_Iter, hms6_Iter, hms7_Iter;
   hash_multiset <int, hash_compare <int, greater<int> > >::iterator
      hms2_Iter;

   // Create an empty hash_multiset hs0 of key type integer
   hash_multiset <int> hs0;

   // Create an empty hash_multiset hms1 with the key comparison
   // function of less than, then insert 4 elements
   hash_multiset <int, hash_compare <int, less<int> > > hms1;
   hms1.insert( 10 );
   hms1.insert( 20 );
   hms1.insert( 30 );
   hms1.insert( 40 );

   // Create an empty hash_multiset hms2 with the key comparison
   // function of geater than, then insert 2 elements
   hash_multiset <int, hash_compare <int, greater<int> > > hms2;
   hms2.insert( 10 );
   hms2.insert( 20 );

   // Create a hash_multiset hms3 with the 
   // allocator of hash_multiset hms1
   hash_multiset <int>::allocator_type hms1_Alloc;
   hms1_Alloc = hms1.get_allocator( );
   hash_multiset <int> hms3( hash_compare <int, less<int> >( ),
      hms1_Alloc );
   hms3.insert( 30 );

   // Create a copy, hash_multiset hms4, of hash_multiset hms1
   hash_multiset <int> hms4( hms1 );

   // Create a hash_multiset hms5 by copying the range hms1[_First, _Last)
   hash_multiset <int>::const_iterator hms1_bcIter, hms1_ecIter;
   hms1_bcIter = hms1.begin( );
   hms1_ecIter = hms1.begin( );
   hms1_ecIter++;
   hms1_ecIter++;
   hash_multiset <int> hms5( hms1_bcIter, hms1_ecIter );

   // Create a hash_multiset hms6 by copying the range hms4[_First, _Last)
   // and with the allocator of hash_multiset hms2
   hash_multiset <int>::allocator_type hms2_Alloc;
   hms2_Alloc = hms2.get_allocator( );
   hash_multiset <int> hms6( hms4.begin( ), ++hms4.begin( ), 
      less<int>( ), hms2_Alloc );

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

   cout << "hms3 = ";
   for ( hms3_Iter = hms3.begin( ); hms3_Iter != hms3.end( );
         hms3_Iter++ )
      cout << *hms3_Iter << " ";
   cout << endl;

   cout << "hms4 = ";
   for ( hms4_Iter = hms4.begin( ); hms4_Iter != hms4.end( );
         hms4_Iter++ )
      cout << *hms4_Iter << " ";
   cout << endl;

   cout << "hms5 = ";
   for ( hms5_Iter = hms5.begin( ); hms5_Iter != hms5.end( );
         hms5_Iter++ )
      cout << *hms5_Iter << " ";
   cout << endl;

   cout << "hms6 = ";
   for ( hms6_Iter = hms6.begin( ); hms6_Iter != hms6.end( );
         hms6_Iter++ )
      cout << *hms6_Iter << " ";
   cout << endl;

    // Create a copy, hash_multiset hms7, of hash_multiset hms1 by moving
    hash_multiset <int, hash_compare <int, less<int> > >
        hms7(move(hms1);
    cout << "hms7 =";
    for (hms7_Iter = hms7.begin(); hms7_Iter != hms7.end(); hms7_Iter++)
        cout << " " << hms7_Iter -> second;
    cout << endl;
}

Output

hms1 = 40 10 20 30 
hms2 = 10 20 
hms3 = 30 
hms4 = 40 10 20 30 
hms5 = 40 10 
hms6 = 40 
hms7 = 40 10 20 30 

요구 사항

헤더: <hash_set>

네임 스페이스: stdext

참고 항목

참조

hash_multiset Class

표준 템플릿 라이브러리