Aracılığıyla paylaş


hash_set::hash_set

[!NOT]

Bu API artık kullanılmıyor.Alternatif unordered_set Class.

Oluşturan bir hash_set yani boş veya yani bir kopyasını tüm veya bazı diğer parçası hash_set.

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

Parametreler

Parametre

Tanımlama

_Al

Bunun için kullanılacak depolama ayırıcısı sınıfı hash_set varsayılan olarak nesnenin Allocator.

_Comp

Karşılaştırma işlevi türü const Traits içindeki öğeleri sıralamak için kullanılan hash_set, varsayılan olarak hash_compare.

_Right

hash_set Biri yapılandırılmış hash_set bir kopyası olacak.

_First

Kopyalanacak öğeleri aralığındaki ilk öğenin konumu.

_Last

Kopyalanacak öğeleri aralık dışına ilk öğenin konumu.

Notlar

Bütün depolamak için bellek depolama yönetir ayırıcısı nesnesi türü hash_set ve, daha sonra döndürülmesi çağırarak hash_set::get_allocator.Ayırıcı parametresi sınıf bildirimleri ve alternatif ayırıcılarına yerine kullanılan önişlem makrolar genellikle atlandı.

Bütün bunların hash_sets başlatın.

Bütün mağaza işlevi nesne türü Traits anahtarları arasında bir sipariş oluşturmak için kullanılan hash_set ve, daha sonra döndürülmesi çağırarak hash_set::key_comp.Daha fazla bilgi için Traits bkz: hash_set Class konu.

Sonraki üç kurucuları boş bir ilk belirtmek hash_set, ikinci karşılaştırma işlevi türü belirtme (_Comp) öğelerini ve üçüncü sırası oluşturma işleminde kullanılacak ayırıcı açıkça belirterek yazın (_Al) kullanılacak.Anahtar sözcük explicit belirli türde otomatik tür dönüşümü bastırır.

Dördüncü yapıcı bir kopyasını belirtir hash_set_Right.

Son üç kurucuları aralığı kopyalayın [_First, _Last), bir hash_set ile karşılaştırma işlevi sınıf nitelikler ve ayırıcısı türünü belirleyen, explicitness artıyor.

Son yapıcı taşır hash_set_Right.

Öğelerin sırasını gerçek bir hash_set , sıralama işlevi geçerli boyutunu karma tablo ve burada onu belirlendi sıralama işlevi tarafından tek başına kümesi konteynerle verebilir gibi genel olarak, bilinemez karma işlev kapsayıcı bağlıdır.

Örnek

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

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_set <int>::iterator hs1_Iter, hs3_Iter, hs4_Iter,
      hs5_Iter, hs6_Iter, hs7_Iter;
   hash_set <int, hash_compare <int, greater<int> > >::iterator
      hs2_Iter;

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

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

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

   // Create a hash_set hs3 with the 
   // allocator of hash_set hs1
   hash_set <int>::allocator_type hs1_Alloc;
   hs1_Alloc = hs1.get_allocator( );
   hash_set <int> hs3( hash_compare <int, less<int> >( ),
      hs1_Alloc );
   hs3.insert( 30 );

   // Create a copy, hash_set hs4, of hash_set hs1
   hash_set <int> hs4( hs1 );

   // Create a hash_set hs5 by copying the range hs1[_First, _Last)
   hash_set <int>::const_iterator hs1_bcIter, hs1_ecIter;
   hs1_bcIter = hs1.begin( );
   hs1_ecIter = hs1.begin( );
   hs1_ecIter++;
   hs1_ecIter++;
   hash_set <int> hs5( hs1_bcIter, hs1_ecIter );

   // Create a hash_set hs6 by copying the range hs4[_First, _Last)
   // and with the allocator of hash_set hs2
   hash_set <int>::allocator_type hs2_Alloc;
   hs2_Alloc = hs2.get_allocator( );
   hash_set <int> hs6( hs4.begin( ), ++hs4.begin( ), 
      less<int>( ), hs2_Alloc );

   cout << "hs1 = ";
   for ( hs1_Iter = hs1.begin( ); hs1_Iter != hs1.end( );
         hs1_Iter++ )
      cout << *hs1_Iter << " ";
   cout << endl;
   
   cout << "hs2 = " ;
   for ( hs2_Iter = hs2.begin( ); hs2_Iter != hs2.end( );
         hs2_Iter++ )
      cout << *hs2_Iter << " ";
   cout << endl;

   cout << "hs3 = ";
   for ( hs3_Iter = hs3.begin( ); hs3_Iter != hs3.end( );
         hs3_Iter++ )
      cout << *hs3_Iter << " ";
   cout << endl;

   cout << "hs4 = ";
   for ( hs4_Iter = hs4.begin( ); hs4_Iter != hs4.end( );
         hs4_Iter++ )
      cout << *hs4_Iter << " ";
   cout << endl;

   cout << "hs5 = ";
   for ( hs5_Iter = hs5.begin( ); hs5_Iter != hs5.end( );
         hs5_Iter++ )
      cout << *hs5_Iter << " ";
   cout << endl;

   cout << "hs6 = ";
   for ( hs6_Iter = hs6.begin( ); hs6_Iter != hs6.end( );
         hs6_Iter++ )
      cout << *hs6_Iter << " ";
   cout << endl;

    // Create a copy, hash_set hs7, of hash_set hs1 by moving
    hash_set <int, hash_compare <int, less<int> > >
        hs7(move(hs1);
    cout << "hs7 =";
    for (hs7_Iter = hs7.begin(); hs7_Iter != hs7.end(); hs7_Iter++)
        cout << " " << hs7_Iter -> second;
    cout << endl;
}

Çıktı

hs1 = 40 10 20 30 
hs2 = 10 20 
hs3 = 30 
hs4 = 40 10 20 30 
hs5 = 40 10 
hs6 = 40 
hs7 = 40 10 20 30 

Gereksinimler

Başlık: <hash_set>

Ad alanı: stdext

Ayrıca bkz.

Başvuru

hash_set Class

Standart Şablon Kütüphanesi