Sdílet prostřednictvím


hash_multiset::hash_multiset

[!POZNÁMKA]

Toto rozhraní API je zastaralé.Alternativou je unordered_multiset Class.

Konstrukce hash_multiset je prázdné nebo je kopírovat všechny nebo některé další část 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
};

Parametry

Parametr

Description

_Al

Třída přidělování úložiště pro tento hash_multiset objekt, který se standardně Allocator.

_Comp

Porovnání funkce typu const Traits pro prvky v pořadí hash_multiset, které výchozí hash_compare.

_Right

hash_multiset z nichž vyrobeno hash_multiset musí být kopie.

_First

První prvek pozice v rozsahu prvků, které mají být zkopírovány.

_Last

Pozice první prvek mimo rozsah prvků, které mají být zkopírovány.

Poznámky

Typ objektu přidělování, který spravuje úložiště paměti pro ukládání všechny konstruktory hash_multiset a později, může vrácený voláním hash_multiset::get_allocator.Parametr přidělování je často vynechán předzpracování makra použít náhradní alternativní allocators a deklarace třídy.

Všechny konstruktory inicializovat jejich hash_multisets.

Uložit všechny konstruktory funkce objekt typu Traits , se používá k vytvoření objednávky mezi klíče hash_multiset a později, může vrácený voláním hash_multiset::key_comp.Další informace o Traits najdete hash_multiset Class téma.

První tři konstruktory zadat prázdný počáteční hash_multiset, druhé určující typ porovnání funkce (_Comp) používané při stanovení pořadí prvků a třetí explicitně zadáním přidělujícího modulu zadejte (_Al) má být použita.Klíčové slovo explicit potlačí určité druhy automatické typ převodu.

Čtvrtý konstruktor určuje kopii hash_multiset_Right.

Zkopírujte následující tři konstruktory [_First,_Last) z hash_multiset s rostoucí explicitness v určující typ porovnání funkce třídy porovnat a přidělování.

Poslední konstruktor přesune hash_multiset_Right.

Skutečné pořadí prvků v kontejneru hash nastavení závisí na funkci hash funkce řazení a aktuální velikost tabulky hash a nelze předpovědět obecně, jako by sada kontejneru, kde byla určena samotné funkce řazení.

Příklad

// 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;
}

Výsledek

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 

Požadavky

Záhlaví: <hash_set>

Obor názvů: stdext

Viz také

Referenční dokumentace

hash_multiset Class

Standardní šablona knihovny