Aracılığıyla paylaş


hash_multimap::insert

[!NOT]

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

Bir öğe veya öğe aralığı bir hash_multimap ekler.

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
);

Parametreler

Parametre

Tanımlama

_Val

Hash_multimap, öğe veya daha genel anahtar eşdeğer sipariş öğe içermiyorsa, hash_multimap Eklenecek öğenin değerini.

_Where

Ekleme noktasını doğru için aramayı başlatmak için yer ile ilgili bir ipucu.

_First

Eşlem'den kopyalanacak ilk öğenin konumu.

_Last

Yalnızca bir eşlem'den kopyalanacak son öğenin ötesinde pozisyon.

Dönüş Değeri

İlk iki Ekle üye işlevleri yeni öðe eklenir nerede konumu işaret eden bir yineleyici döndürür.

Son iki Ekle üye işlevleri davranır ilk ikisi aynı yapısı eklenen değer taşınabilecek dışında.

Notlar

Value_type böylece bir öğenin değerini ilk bileşen anahtar değerine eşit ve öğenin veri değerine eşit ikinci bileşeni sıralı çiftiyle bir bir çift öğesidir.

Ekleme oluşabilir Logaritmik saat yerine INSERT ipucu sürümü için amortized sabit zaman hemen ekleme noktasını izleyen, _Where.

Yineleyici aralıktaki tarafından gönderilen her öğeye karşılık gelen bir harita öğesi değerleri dizisi üçüncü üye işlevini ekler [_First, _Last) belirtilen kümesi.

Örnek

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

Gereksinimler

Başlık: <hash_map>

Ad alanı: stdext

Ayrıca bkz.

Başvuru

hash_multimap Class

Standart Şablon Kütüphanesi