Aracılığıyla paylaş


hash_multimap Sınıfı

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Kapsayıcı sınıfı hash_multimap, C++ Standart Kitaplığı'nın bir uzantısıdır ve her öğenin benzersiz olması gerekmeyen bir sıralama anahtarına ve ilişkili veri değerine sahip bir çift olduğu bir koleksiyondan verilerin depolanması ve hızlı alınması için kullanılır.

Sözdizimi

template <class Key,
    class Type,
    class Traits=hash_compare <Key, less <Key>>,
    class Allocator=allocator <pair  <const Key, Type>>>
class hash_multimap

Parametreler

Anahtar
hash_multimap depolanacak anahtar veri türü.

Tür
hash_multimap depolanacak öğe veri türü.

Özellik
İki işlev nesnesi içeren tür, göreli düzenlerini belirlemek için sıralama anahtarları olarak iki öğe değerini karşılaştırabilen sınıf Niteliklerinden biri ve öğelerin birli koşul eşleme anahtar değerlerini türündeki size_tişaretsiz tamsayılarla eşleyen bir karma işlevidir. Bu bağımsız değişken isteğe bağlıdır ve hash_compare<Key, less<Key>> varsayılan değerdir.

Ayırıcı
hash_multimap ayırma ve bellek ayırma hakkındaki ayrıntıları kapsülleyen depolanmış ayırıcı nesnesini temsil eden tür. Bu bağımsız değişken isteğe bağlıdır ve varsayılan değerdir allocator<pair <const Key, Type>>.

Açıklamalar

hash_multimap:

  • İlişkili bir anahtar değerine dayalı öğe değerlerinin verimli alınmasını destekleyen bir değişken boyutu kapsayıcı olan ilişkilendirilebilir bir kapsayıcı.

  • Çift yönlüdür, çünkü öğelerine erişmek için çift yönlü bir yineleyici sağlar.

  • Karma, çünkü öğeleri öğelerinin anahtar değerlerine uygulanan bir karma işlevinin değerine göre demetler halinde gruplandırılır.

  • Öğelerinin benzersiz anahtarlara ihtiyacı olmaması için çokludur, böylece bir anahtar değer onunla ilişkili çok sayıda öğe verisi değerine sahip olabilir.

  • Öğe değerleri anahtar değerlerinden ayrı olduğundan, bir çift ilişkilendirici kapsayıcı.

  • Sınıf şablonu, sağladığı işlevsellik genel olduğundan ve öğeler veya anahtarlar olarak yer alan belirli veri türlerinden çok bağımsızdır. Öğeler ve anahtarlar için kullanılacak veri türleri, karşılaştırma işlevi ve ayırıcı ile birlikte bir sınıf şablonunda parametreler olarak belirtilir.

Sıralamaya göre karma oluşturmanın temel avantajı daha yüksek verimliliktir; başarılı bir karma ekleme, silme işlemleri gerçekleştirir ve sıralama teknikleri için kapsayıcıdaki öğe sayısının logaritmasıyla orantılı bir süreyle karşılaştırıldığında sabit ortalama süre bulur. hash_multimap içindeki bir öğenin değeri, ancak ilişkili anahtar değeri doğrudan değiştirilebilir. Bunun yerine, eski öğelerle ilişkili anahtar değerleri silinmeli ve eklenen yeni öğelerle ilişkili yeni anahtar değerleri eklenmelidir.

Kapsayıcı türünün seçimi genelde uygulamanın gerektirdiği arama ve ekleme türüne dayalı olmalıdır. Karma ilişkilendirme kapsayıcıları arama, ekleme ve kaldırma işlemleri için iyileştirilmiştir. Bu işlemleri açıkça destekleyen üye işlevleri, iyi tasarlanmış bir karma işleviyle kullanıldığında verimlidir ve bunları ortalama sabit olan ve kapsayıcıdaki öğe sayısına bağımlı olmayan bir zamanda gerçekleştirir. İyi tasarlanmış bir karma işlevi, karma değerlerin tekdüzen bir dağılımını oluşturur ve çakışma sayısını en aza indirir. Burada, farklı anahtar değerleri aynı karma değere eşlendiğinde çakışma olduğu söylenir. En kötü durumda, mümkün olan en kötü karma işleviyle, işlem sayısı dizideki öğe sayısıyla orantılıdır (doğrusal süre).

Değerleri anahtarlarıyla ilişkilendiren koşullar uygulama tarafından karşılandığında, hash_multimap tercih edilen ilişkilendirilebilir kapsayıcı olmalıdır. Bu tür bir yapı için model, mesela açıklamalar sağlayan dize değerleriyle ilişkili anahtar sözcüklerin sıralı bir listesidir, burada sözcükler her zaman benzersiz olarak tanımlanmamıştır. Bunun yerine anahtar sözcükler benzersiz olarak tanımlandıysa ve anahtarlar benzersizse, hash_map tercih edilen kapsayıcı olacaktır. Öte yandan, yalnızca sözcüklerin listesi depolanıyorsa, hash_set doğru kapsayıcı olacaktır. Sözcüklerin birden çok örneğine izin verilseydi, hash_multiset uygun kapsayıcı yapısı olurdu.

hash_multimap, value_compareTraitsbir depolanmış karma nesnesi çağırarak denetlediği sırayı sıralar. Bu depolanan nesneye üye işlevi key_comp çağrılarak erişilebilir. Böyle bir işlev nesnesi, sınıf hash_compare<Key, less<Key>> nesnesiyle aynı şekilde davranmalıdır. Özellikle, türündeki Keytüm değerler Key için çağrısı Traits (Key) türündeki değerlerin dağılımını size_tverir.

Genelde, bu sıralamayı oluşturmak için öğelerin yalnızca küçüktür biçiminde karşılaştırılabilir olması gerekir; böylece, herhangi iki öğe belirtildiğinde, eşit oldukları (yani birinin diğerinden daha küçük olmadığı anlamında) veya birinin diğerinden küçük olduğu belirlenebilir. Bu, eşdeğer olmayan öğeler arasında bir sıralamaya neden olur. Daha teknik bir not üzerinde, karşılaştırma işlevi standart matematiksel anlamda katı bir zayıf sıralama sevk eden ikili bir koşuldur. İkili koşul f(x, y), iki bağımsız değişken nesnesi ve x veya ydönüş değerine true sahip bir işlev nesnesidirfalse. bir hash_multimap uygulanan sıralama, ikili koşul esnek değilse, antisymetrik ve geçişliyse ve denklik geçişliyse, iki nesnenin xy ve hem f(x, y) hem de f(y, x) olduğunda eşdeğer olarak tanımlandığı katı bir zayıf sıralamadır false. Anahtarlar arasındaki eşitliğinin daha güçlü koşulu bu denkliğin yerini alırsa, sıralama (içindeki tüm öğelerin birbirine göre sıralanması anlamında) toplam haline gelir ve eşleşen anahtarlar birbirinden ayırt edilemez olacaktır.

Denetlenen dizideki öğelerin gerçek sırası karma işlevine, sıralama işlevine ve kapsayıcı nesnesinde depolanan karma tablosunun geçerli boyutuna bağlıdır. Karma tablosunun geçerli boyutunu belirleyemezsiniz, bu nedenle denetimli dizideki öğelerin sırasını genel olarak tahmin edemezsiniz. Öğelerin eklenmesi hiçbir yineleyiciyi geçersiz kılmaz; öğelerin kaldırılması yalnızca özellikle kaldırılan öğeleri gösteren yineleyicileri geçersiz kılar.

hash_multimap sınıfı tarafından sağlanan yineleyici çift yönlü bir yineleyicidir, ancak sınıf üyesi işlevleri ekleme ve hash_multimap , işlev gereksinimleri çift yönlü yineleyici sınıfı tarafından garanti edilenden daha düşük olan şablon parametreleri olarak daha zayıf bir giriş yineleyicisi alan sürümlere sahiptir. Farklı yineleyici kavramları, işlevselliklerindeki iyileştirmelere göre ilgili bir aile biçimlendirir. Her yineleyici kavramının kendi hash_multimap gereksinimleri vardır ve bunlarla çalışan algoritmaların varsayımlarını bu tür yineleyici tarafından sağlanan gereksinimlerle sınırlaması gerekir. Bir giriş yineleyicinin bazı nesnelere başvurusunun kaldırılacağı ve dizideki sonraki yineleyiciye artırılabileceği varsayılabilir. Bu en az işlev hash_multimap, ancak üye işlevleri bağlamında bir dizi yineleyici [First, Last) hakkında anlamlı bir şekilde konuşabilmek yeterlidir.

Oluşturucular

Oluşturucu Açıklama
hash_multimap Belirli bir boyutun listesini veya belirli bir değerin öğeleriyle ya da belirli bir veya başka allocatorbir hash_multimap öğesinin kopyası olarak oluşturur.

Tür tanımları

Tür adı Açıklama
allocator_type Nesnenin sınıfını allocatorhash_multimap temsil eden bir tür.
const_iterator içindeki bir öğeyi constokuyabilen çift yönlü bir yineleyici sağlayan türhash_multimap.
const_pointer içindeki bir const öğeye işaretçi sağlayan tür hash_multimap.
const_reference okuma ve gerçekleştirme const işlemleri için içinde hash_multimap depolanan bir const öğeye başvuru sağlayan bir tür.
const_reverse_iterator içindeki constherhangi hash_multimap bir öğeyi okuyabilen çift yönlü bir yineleyici sağlayan tür.
difference_type Yineleyiciler tarafından işaret edilen öğeler arasındaki bir aralıktaki öğelerinin hash_multimap sayısını göstermek için kullanılabilecek imzalı bir tamsayı türü.
Yineleyici bir içindeki herhangi bir öğeyi okuyabilen veya değiştirebilen çift yönlü bir yineleyici sağlayan tür hash_multimap.
key_compare içindeki iki öğeye hash_multimapgöre sırasını belirlemek için iki sıralama anahtarını karşılaştırabilen bir işlev nesnesi sağlayan tür.
key_type öğesinin her öğesini hash_multimapoluşturan sıralama anahtarı nesnesini açıklayan bir tür.
mapped_type içinde depolanan veri türünü temsil eden bir hash_multimaptür.
Işaretçi içindeki bir öğeye işaretçi sağlayan tür hash_multimap.
referans içinde depolanan bir öğeye başvuru sağlayan tür hash_multimap.
reverse_iterator Ters çevrilmiş hash_multimapiçindeki bir öğeyi okuyabilen veya değiştirebilen çift yönlü bir yineleyici sağlayan tür.
size_type içindeki öğe sayısını temsil eden işaretsiz bir hash_multimaptamsayı türü.
value_type içinde göreli düzenlerini hash_multimapbelirlemek için iki öğeyi sıralama anahtarları olarak karşılaştırabilen bir işlev nesnesi sağlayan tür.

Üye işlevleri

Üye işlevi Açıklama
başlamak içindeki ilk öğeyi hash_multimapele alan bir yineleyici döndürür.
cbegin içindeki ilk öğeyi hash_multimapele alan bir sabit yineleyici döndürür.
cend bir içindeki son öğenin başarılı olduğu konumu ele alan bir hash_multimapsabit yineleyici döndürür.
berrak öğesinin hash_multimaptüm öğelerini siler.
sayı Anahtarı parametre tarafından belirtilen anahtarla eşleşen bir hash_multimap içindeki öğelerin sayısını döndürür.
crbegin ters çevrilmiş hash_multimapiçindeki ilk öğeyi ele alan bir sabit yineleyici döndürür.
crend Ters çevrilmiş hash_multimapbir içindeki son öğeyi başaran konumu ele alan bir sabit yineleyici döndürür.
yer değiştirme içine yerinde inşa edilmiş bir hash_multimapöğe ekler.
emplace_hint Bir yerleştirme ipucuyla içine yerinde hash_multimapinşa edilmiş bir öğe ekler.
boş boş hash_multimap olup olmadığını sınar.
son içindeki son öğenin başarılı olduğu konumu ele alan bir hash_multimapyineleyici döndürür.
equal_range içindeki son öğenin başarılı olduğu konumu ele alan bir hash_multimapyineleyici döndürür.
silmek Belirtilen konumlardan bir öğeyi veya öğe hash_multimap aralığını kaldırır
bulmak Belirtilen anahtara eşdeğer bir anahtara sahip bir hash_multimap öğenin konumunu adresleyen bir yineleyici döndürür.
get_allocator oluşturmak için kullanılan nesnesinin allocatorbir kopyasını hash_multimap döndürür.
sokmak Belirtilen konumda öğesine hash_multimap bir öğe veya öğe aralığı ekler.
key_comp içindeki anahtarları sıralamak için kullanılan karşılaştırma nesnesinin bir hash_multimapkopyasını alır.
lower_bound Bir yineleyiciyi, belirtilen anahtarın değerine eşit veya ondan daha büyük bir anahtar değeri olan bir içindeki ilk öğeye hash_multimap döndürür.
max_size değerinin uzunluk üst sınırını hash_multimapdöndürür.
rbegin ters çevrilmiş hash_multimapiçindeki ilk öğeyi ele alan bir yineleyici döndürür.
yarmak Ters çevrilmiş hash_multimapbir içindeki son öğeyi başaran konumu ele alan bir yineleyici döndürür.
boyut için yeni bir hash_multimapboyut belirtir.
değiş tokuş etmek İki hash_multimapöğesinin öğelerini değiştirir.
upper_bound Belirtilen anahtarın değerinden daha büyük bir hash_multimap anahtar değeri olan bir içindeki ilk öğeye bir yineleyici döndürür.
value_comp içindeki öğe değerlerini sıralamak için kullanılan karşılaştırma nesnesinin bir hash_multimapkopyasını alır.

İşleçler

Operatör Açıklama
hash_multimap::operator= öğesinin hash_multimap öğelerini başka hash_multimapbir kopyasının kopyasıyla değiştirir.

Gereksinimler

Üst Bilgi:<hash_map>

Ad alanı: stdext

hash_multimap::allocator_type

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

hash_multimap nesnesi için ayırıcı sınıfını temsil eden bir tür.

typedef list<typename Traits::value_type, typename Traits::allocator_type>::allocator_type allocator_type;

Açıklamalar

allocator_type , şablon parametresinin Allocatoreş anlamlısıdır.

hakkında Allocatordaha fazla bilgi için hash_multimap Sınıfı konusunun Açıklamalar bölümüne bakın.

Örnek

kullanan bir örnek için allocator_type örneğine bakın.

hash_multimap::begin

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

hash_multimap ilk öğeyi ele alan bir yineleyici döndürür.

const_iterator begin() const;

iterator begin();

Dönüş Değeri

hash_multimap ilk öğeyi veya boş bir hash_multimap başarılı olan konumu ele alan çift yönlü bir yineleyici.

Açıklamalar

dönüş değeri begin öğesine const_iteratoratanmışsa, hash_multimap nesnesindeki öğeler değiştirilemez. dönüş değeri begin bir iteratoröğesine atanmışsa, hash_multimap nesnesindeki öğeler değiştirilebilir.

Örnek

// hash_multimap_begin.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1;

   hash_multimap <int, int> :: iterator hm1_Iter;
   hash_multimap <int, int> :: const_iterator hm1_cIter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 0, 0 ) );
   hm1.insert ( Int_Pair ( 1, 1 ) );
   hm1.insert ( Int_Pair ( 2, 4 ) );

   hm1_cIter = hm1.begin ( );
   cout << "The first element of hm1 is " << hm1_cIter -> first
        << "." << endl;

   hm1_Iter = hm1.begin ( );
   hm1.erase ( hm1_Iter );

   // The following 2 lines would err because the iterator is const
   // hm1_cIter = hm1.begin ( );
   // hm1.erase ( hm1_cIter );

   hm1_cIter = hm1.begin( );
   cout << "The first element of hm1 is now " << hm1_cIter -> first
        << "." << endl;
}
The first element of hm1 is 0.
The first element of hm1 is now 1.

hash_multimap::cbegin

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

hash_multimap ilk öğeyi ele alan bir sabit yineleyici döndürür.

const_iterator cbegin() const;

Dönüş Değeri

hash_multimap ilk öğeyi veya boş hash_multimapbir öğesinin başarılı olduğu konumu ele alan iki yönlü bir sabit yineleyici.

Örnek

// hash_multimap_cbegin.cpp
// compile with: /EHsc
#include <hash_multimap>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1;

   hash_multimap <int, int> :: const_iterator hm1_cIter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 2, 4 ) );

   hm1_cIter = hm1.cbegin ( );
   cout << "The first element of hm1 is "
        << hm1_cIter -> first << "." << endl;
   }
The first element of hm1 is 2.

hash_multimap::cend

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

bir hash_multimap son öğesinin başarılı olduğu konumu ele alan bir sabit yineleyici döndürür.

const_iterator cend() const;

Dönüş Değeri

Bir hash_multimap son öğesinin başarılı olduğu konumu ele alan çift yönlü bir sabit yineleyici. hash_multimap boşsa, öğesini seçinhash_multimap::cend == hash_multimap::begin.

Açıklamalar

cend bir yineleyicinin hash_multimap sonuna ulaşıp ulaşmadığını test etmek için kullanılır.

tarafından cend döndürülen değer başvurulmamalıdır.

Örnek

// hash_multimap_cend.cpp
// compile with: /EHsc
#include <hash_multimap>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1;

   hash_multimap <int, int> :: const_iterator hm1_cIter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 3, 30 ) );

   hm1_cIter = hm1.cend( );
   hm1_cIter--;
   cout << "The value of last element of hm1 is "
        << hm1_cIter -> second << "." << endl;
   }
The value of last element of hm1 is 30.

hash_multimap::clear

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

bir hash_multimap tüm öğelerini siler.

void clear();

Örnek

Aşağıdaki örnekte hash_multimap::clear üye işlevinin kullanımı gösterilmektedir.

// hash_multimap_clear.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main()
{
    using namespace std;
    using namespace stdext;
    hash_multimap<int, int> hm1;
    hash_multimap<int, int>::size_type i;
    typedef pair<int, int> Int_Pair;

    hm1.insert(Int_Pair(1, 1));
    hm1.insert(Int_Pair(2, 4));

    i = hm1.size();
    cout << "The size of the hash_multimap is initially "
         << i  << "." << endl;

    hm1.clear();
    i = hm1.size();
    cout << "The size of the hash_multimap after clearing is "
         << i << "." << endl;
}
The size of the hash_multimap is initially 2.
The size of the hash_multimap after clearing is 0.

hash_multimap::const_iterator

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

hash_multimap bir öğeyi okuyabilen çift yönlü yineleyici sağlayan bir const tür.

typedef list<typename Traits::value_type, typename Traits::allocator_type>::const_iterator const_iterator;

Açıklamalar

Bir öğenin değerini değiştirmek için bir tür const_iterator kullanılamaz.

const_iterator tarafından tanımlanan hash_multimap türündeki value_type nesnelerine işaret ederpair<const Key, Type>. Anahtarın değeri ilk üye çifti aracılığıyla kullanılabilir ve eşlenen öğenin değeri çiftin ikinci üyesi aracılığıyla kullanılabilir.

hash_multimap bir const_iteratorcIter öğeye işaret eden bir başvuruyu geri almak için işlecini -> kullanın.

öğesinin anahtarının değerine erişmek için, cIter->firstile eşdeğer (*cIter).firstolan kullanın. öğesinin eşlenmiş veri kümesinin değerine erişmek için öğesine cIter->secondeşdeğer (*cIter).secondolan kullanın.

Örnek

kullanarak bir örnek için const_iterator örneğine bakın.

hash_multimap::const_pointer

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

hash_multimap bir const öğeye işaretçi sağlayan tür.

typedef list<typename _Traits::value_type, typename _Traits::allocator_type>::const_pointer const_pointer;

Açıklamalar

Bir öğenin değerini değiştirmek için bir tür const_pointer kullanılamaz.

Çoğu durumda, bir hash_multimap nesnesindeki öğelere erişmek için yineleyici kullanılmalıdır.

hash_multimap::const_reference

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

okuma ve işlem gerçekleştirmeye const yönelik bir const hash_multimap depolanan bir öğeye başvuru sağlayan bir tür.

typedef list<typename _Traits::value_type, typename _Traits::allocator_type>::const_reference const_reference;

Örnek

// hash_multimap_const_ref.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap<int, int> hm1;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 1, 10 ) );
   hm1.insert ( Int_Pair ( 2, 20 ) );

   // Declare and initialize a const_reference &Ref1
   // to the key of the first element
   const int &Ref1 = ( hm1.begin( ) -> first );

   // The following line would cause an error because the
   // non-const_reference cannot be used to access the key
   // int &Ref1 = ( hm1.begin( ) -> first );

   cout << "The key of first element in the hash_multimap is "
        << Ref1 << "." << endl;

   // Declare and initialize a reference &Ref2
   // to the data value of the first element
   int &Ref2 = ( hm1.begin() -> second );

   cout << "The data value of 1st element in the hash_multimap is "
        << Ref2 << "." << endl;
}
The key of first element in the hash_multimap is 1.
The data value of 1st element in the hash_multimap is 10.

hash_multimap::const_reverse_iterator

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

hash_multimap herhangi const bir öğeyi okuyabilen çift yönlü bir yineleyici sağlayan tür.

typedef list<typename Traits::value_type, typename Traits::allocator_type>::const_reverse_iterator const_reverse_iterator;

Açıklamalar

Bir tür const_reverse_iterator bir öğenin değerini değiştiremez ve hash_multimap tersten yinelemek için kullanılır.

const_reverse_iterator hash_multimap tarafından tanımlanan, ilkişaret eder.

hash_multimap bir const_reverse_iteratorcrIter öğeye işaret eden bir başvuruyu geri almak için işlecini -> kullanın.

öğesinin anahtarının değerine erişmek için, crIter->firstile eşdeğer (*crIter).firstolan kullanın. öğesinin eşlenmiş veri kümesinin değerine erişmek için öğesine crIter->secondeşdeğer (*crIter).secondolan kullanın.

Örnek

nasıl bildirilip kullanılacağına ilişkin bir örnek için rend örneğine const_reverse_iteratorbakın.

hash_multimap::count

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Anahtarı parametre tarafından belirtilen anahtarla eşleşen bir hash_multimap öğe sayısını döndürür.

size_type count(const Key& key) const;

Parametreler

anahtar
hash_multimap eşleştirilecek öğelerin anahtarı.

Dönüş Değeri

hash_multimap sıralama anahtarı parametre anahtarıyla eşleşen bir öğe içeriyorsa 1; hash_multimap eşleşen anahtara sahip bir öğe içermiyorsa 0.

Açıklamalar

Üye işlevi aralıktaki öğe sayısını döndürür

[lower_bound (key), upper_bound (key) )

anahtar değer anahtarına sahiptir.

Örnek

Aşağıdaki örnekte hash_multimap::count üye işlevinin kullanımı gösterilmektedir.

// hash_multimap_count.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
    using namespace std;
    using namespace stdext;
    hash_multimap<int, int> hm1;
    hash_multimap<int, int>::size_type i;
    typedef pair<int, int> Int_Pair;

    hm1.insert(Int_Pair(1, 1));
    hm1.insert(Int_Pair(2, 1));
    hm1.insert(Int_Pair(1, 4));
    hm1.insert(Int_Pair(2, 1));

    // Elements do not need to have unique keys in hash_multimap,
    // so duplicates are allowed and counted
    i = hm1.count(1);
    cout << "The number of elements in hm1 with a sort key of 1 is: "
         << i << "." << endl;

    i = hm1.count(2);
    cout << "The number of elements in hm1 with a sort key of 2 is: "
         << i << "." << endl;

    i = hm1.count(3);
    cout << "The number of elements in hm1 with a sort key of 3 is: "
         << i << "." << endl;
}
The number of elements in hm1 with a sort key of 1 is: 2.
The number of elements in hm1 with a sort key of 2 is: 2.
The number of elements in hm1 with a sort key of 3 is: 0.

hash_multimap::crbegin

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Ters çevrilmiş bir hash_multimap ilk öğeyi ele alan bir sabit yineleyici döndürür.

const_reverse_iterator crbegin() const;

Dönüş Değeri

Ters çevrilmiş bir hash_multimap içindeki ilk öğeyi veya ters çevrilmemiş hash_multimapiçindeki son öğeyi ele alan en ters çift yönlü yineleyici.

Açıklamalar

crbegin , hash_multimap ::begin gibi ters çevrilmiş bir hash_multimaphash_multimap ile kullanılır.

dönüş değeriyle crbeginhash_multimap nesne değiştirilemez.

crbegin geriye doğru yinelemek hash_multimap için kullanılabilir.

Örnek

// hash_multimap_crbegin.cpp
// compile with: /EHsc
#include <hash_multimap>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1;

   hash_multimap <int, int> :: const_reverse_iterator hm1_crIter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 3, 30 ) );

   hm1_crIter = hm1.crbegin( );
   cout << "The first element of the reversed hash_multimap hm1 is "
        << hm1_crIter -> first << "." << endl;
}
The first element of the reversed hash_multimap hm1 is 3.

hash_multimap::crend

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Ters çevrilmiş bir hash_multimap son öğenin başarılı olduğu konumu ele alan bir sabit yineleyici döndürür.

const_reverse_iterator crend() const;

Dönüş Değeri

Ters çevrilmiş bir hash_multimap son öğeyi (ters hash_multimapçevrilmemiş öğedeki ilk öğeden önce gelen konum) başarılı olan konumu ele alan en büyük ters çift yönlü yineleyici.

Açıklamalar

crendhash_multimap::end bir hash_multimap kullanıldığında olduğu gibi ters çevrilmiş bir hash_multimap ile kullanılır.

dönüş değeriyle crendhash_multimap nesne değiştirilemez.

crend bir ters yineleyicinin hash_multimap sonuna ulaşıp ulaşmadığını test etmek için kullanılabilir.

tarafından crend döndürülen değer başvurulmamalıdır.

Örnek

// hash_multimap_crend.cpp
// compile with: /EHsc
#include <hash_multimap>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1;

   hash_multimap <int, int> :: const_reverse_iterator hm1_crIter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 3, 30 ) );

   hm1_crIter = hm1.crend( );
   hm1_crIter--;
   cout << "The last element of the reversed hash_multimap hm1 is "
        << hm1_crIter -> first << "." << endl;
}
The last element of the reversed hash_multimap hm1 is 3.

hash_multimap::d ifference_type

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Yineleyiciler tarafından işaret edilen öğeler arasındaki bir aralıktaki bir hash_multimap öğelerinin sayısını göstermek için kullanılabilecek imzalı bir tamsayı türü.

typedef list<typename _Traits::value_type, typename _Traits::allocator_type>::difference_type difference_type;

Açıklamalar

difference_type, kapsayıcının yineleyicileri çıkarılırken veya artırılırken döndürülen türdür. difference_type genellikle yineleyiciler ile firstarasındaki [ ilk, son)lastöğe sayısını temsil etmek için first kullanılır; tarafından işaret edilen öğeyi ve ile işaret edilen lastöğeyi dahil etmek için değil, öğesine kadar olan öğe aralığını içerir.

Küme gibi geri alınabilir kapsayıcılar tarafından desteklenen çift yönlü yineleyiciler sınıfını içeren bir giriş yineleyicisinin gereksinimlerini karşılayan tüm yineleyiciler için kullanılabilir olsa difference_type da, yineleyiciler arasındaki çıkarma yalnızca vektör gibi rastgele erişimli bir kapsayıcı tarafından sağlanan rastgele erişim yineleyicileri tarafından desteklenir.

Örnek

// hash_multimap_difference_type.cpp
// compile with: /EHsc
#include <iostream>
#include <hash_map>
#include <algorithm>

int main()
{
    using namespace std;
    using namespace stdext;
    hash_multimap<int, int> hm1;
    typedef pair<int, int> Int_Pair;

    hm1.insert(Int_Pair(2, 20));
    hm1.insert(Int_Pair(1, 10));
    hm1.insert(Int_Pair(3, 20));

    // The following will insert, because map keys
    // do not need to be unique
    hm1.insert(Int_Pair(2, 30));

    hash_multimap<int, int>::iterator hm1_Iter, hm1_bIter, hm1_eIter;
    hm1_bIter = hm1.begin();
    hm1_eIter = hm1.end();

    // Count the number of elements in a hash_multimap
    hash_multimap<int, int>::difference_type df_count = 0;
    hm1_Iter = hm1.begin();
    while (hm1_Iter != hm1_eIter)
    {
        df_count++;
        hm1_Iter++;
    }

    cout << "The number of elements in the hash_multimap hm1 is: "
         << df_count << "." << endl;

    cout << "The keys of the mapped elements are:";
    for (hm1_Iter= hm1.begin() ; hm1_Iter!= hm1.end();
        hm1_Iter++)
        cout << " " << hm1_Iter-> first;
    cout << "." << endl;

    cout << "The values of the mapped elements are:";
    for (hm1_Iter= hm1.begin() ; hm1_Iter!= hm1.end();
        hm1_Iter++)
        cout << " " << hm1_Iter-> second;
    cout << "." << endl;
}
The number of elements in the hash_multimap hm1 is: 4.
The keys of the mapped elements are: 1 2 2 3.
The values of the mapped elements are: 10 20 30 20.

hash_multimap::emplace

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Bir hash_multimap yerinde inşa edilmiş bir öğe ekler.

template <class ValTy>
iterator emplace(ValTy&& val);

Parametreler

Val
hash_multimap eklenecek bir öğeyi taşımak için kullanılan değer.

Dönüş Değeri

Üye işlevi, emplace yeni öğenin eklendiği konumu gösteren bir yineleyici döndürür.

Açıklamalar

Bir öğenin hash_multimap::value_type bir çifttir, böylece öğenin değeri ilk bileşen anahtar değerine eşit ve ikinci bileşen öğenin veri değerine eşit olan sıralı bir çift olur.

Örnek

// hash_multimap_emplace.cpp
// compile with: /EHsc
#include <hash_multimap>
#include <iostream>
#include <string>

int main()
{
    using namespace std;
    using namespace stdext;
    hash_multimap<int, string> hm1;
    typedef pair<int, string> is1(1, "a");

    hm1.emplace(move(is1));
    cout << "After the emplace, hm1 contains:" << endl
      << " " << hm1.begin()->first
      << " => " << hm1.begin()->second
      << endl;
}
After the emplace insertion, hm1 contains:
1 => a

hash_multimap::emplace_hint

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Yerleştirme ipucuyla bir hash_multimap yerinde olarak inşa edilmiş bir öğe ekler.

template <class ValTy>
iterator emplace_hint(
    const_iterator _Where,
    ValTy&& val);

Parametreler

Val
Yapıyı taşımak için kullanılan değer, zaten bu öğeyi (veya daha genel olarak anahtarı eşdeğer sıralanmış bir öğe) içermediği sürece hash_multimap eklenecek hash_multimap öğeyi taşır.

_Nerede
Doğru ekleme noktasını aramaya başlama yeriyle ilgili bir ipucu.

Dönüş Değeri

hash_multimap::emplace üye işlevi, yeni öğenin içine eklendiği hash_multimapkonumu gösteren bir yineleyici döndürür.

Açıklamalar

Bir öğenin hash_multimap::value_type bir çifttir, böylece öğenin değeri ilk bileşen anahtar değerine eşit ve ikinci bileşen öğenin veri değerine eşit olan sıralı bir çift olur.

Ekleme noktası hemen _Where izlerse ekleme işlemi logaritmik saat yerine amorti edilmiş sabit sürede gerçekleşebilir.

Örnek

// hash_multimap_emplace_hint.cpp
// compile with: /EHsc
#include <hash_multimap>
#include <iostream>
#include <string>

int main()
{
    using namespace std;
    using namespace stdext;
    hash_multimap<int, string> hm1;
    typedef pair<int, string> is1(1, "a");

    hm1.emplace(hm1.begin(), move(is1));
    cout << "After the emplace insertion, hm1 contains:" << endl
      << " " << hm1.begin()->first
      << " => " << hm1.begin()->second
      << endl;
}
After the emplace insertion, hm1 contains:
1 => a

hash_multimap::empty

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

bir hash_multimap boş olup olmadığını sınar.

bool empty() const;

Dönüş Değeri

true hash_multimap boşsa; false hash_multimap yoksa.

Örnek

// hash_multimap_empty.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1, hm2;

   typedef pair <int, int> Int_Pair;
   hm1.insert ( Int_Pair ( 1, 1 ) );

   if ( hm1.empty( ) )
      cout << "The hash_multimap hm1 is empty." << endl;
   else
      cout << "The hash_multimap hm1 is not empty." << endl;

   if ( hm2.empty( ) )
      cout << "The hash_multimap hm2 is empty." << endl;
   else
      cout << "The hash_multimap hm2 is not empty." << endl;
}
The hash_multimap hm1 is not empty.
The hash_multimap hm2 is empty.

hash_multimap::end

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

bir hash_multimap son öğesinin başarılı olduğu konumu ele alan bir yineleyici döndürür.

const_iterator end() const;

iterator end();

Dönüş Değeri

Bir hash_multimap son öğesinin başarılı olduğu konumu ele alan çift yönlü yineleyici. hash_multimap boşsa hash_multimap::end == hash_multimap::begin.

Açıklamalar

end bir yineleyicinin hash_multimap sonuna ulaşıp ulaşmadığını test etmek için kullanılır.

tarafından end döndürülen değer başvurulmamalıdır.

Örnek

// hash_multimap_end.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1;

   hash_multimap <int, int> :: iterator hm1_Iter;
   hash_multimap <int, int> :: const_iterator hm1_cIter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 1, 10 ) );
   hm1.insert ( Int_Pair ( 2, 20 ) );
   hm1.insert ( Int_Pair ( 3, 30 ) );

   hm1_cIter = hm1.end( );
   hm1_cIter--;
   cout << "The value of last element of hm1 is "
        << hm1_cIter -> second << "." << endl;

   hm1_Iter = hm1.end( );
   hm1_Iter--;
   hm1.erase ( hm1_Iter );

   // The following 2 lines would err because the iterator is const
   // hm1_cIter = hm1.end ( );
   // hm1_cIter--;
   // hm1.erase ( hm1_cIter );

   hm1_cIter = hm1.end( );
   hm1_cIter--;
   cout << "The value of last element of hm1 is now "
        << hm1_cIter -> second << "." << endl;
}
The value of last element of hm1 is 30.
The value of last element of hm1 is now 20.

hash_multimap::equal_range

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Hash_multimap belirtilen anahtardan büyük bir anahtara sahip ilk öğeye ve anahtara eşit veya daha büyük bir anahtara sahip hash_multimap ilk öğeye sırasıyla bir çift yineleyici döndürür.

pair <const_iterator, const_iterator> equal_range (const Key& key) const;

pair <iterator, iterator> equal_range (const Key& key);

Parametreler

anahtar
Aranmakta olan hash_multimap bir öğenin sıralama anahtarıyla karşılaştırılacak bağımsız değişken anahtarı.

Dönüş Değeri

Birincisi anahtarın lower_bound, ikincisi anahtarın upper_bound olacak şekilde bir çift yineleyici.

Üye işlevi tarafından döndürülen bir çiftin pr ilk yineleyicisine erişmek için kullanın pr. önce ve alt sınır yineleyicisini geri almak için *(pr kullanın. önce). Üye işlevi tarafından döndürülen bir çiftin pr ikinci yineleyicisine erişmek için kullanın pr. ikinci ve üst sınır yineleyicisini geri almak için *(pr kullanın. saniye).

Örnek

// hash_multimap_equal_range.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   typedef hash_multimap <int, int> IntMMap;
   IntMMap hm1;
   hash_multimap <int, int> :: const_iterator hm1_RcIter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 1, 10 ) );
   hm1.insert ( Int_Pair ( 2, 20 ) );
   hm1.insert ( Int_Pair ( 3, 30 ) );

   pair <IntMMap::const_iterator, IntMMap::const_iterator> p1, p2;
   p1 = hm1.equal_range( 2 );

   cout << "The lower bound of the element with a key of 2\n"
        << "in the hash_multimap hm1 is: "
        << p1.first -> second << "." << endl;

   cout << "The upper bound of the element with a key of 2\n"
        << "in the hash_multimap hm1 is: "
        << p1.second -> second << "." << endl;

   // Compare the upper_bound called directly
   hm1_RcIter = hm1.upper_bound( 2 );

   cout << "A direct call of upper_bound( 2 ) gives "
        << hm1_RcIter -> second << "," << endl
        << "matching the 2nd element of the pair "
        << "returned by equal_range( 2 )." << endl;

   p2 = hm1.equal_range( 4 );

   // If no match is found for the key,
   // both elements of the pair return end( )
   if ( ( p2.first == hm1.end( ) ) && ( p2.second == hm1.end( ) ) )
      cout << "The hash_multimap hm1 doesn't have an element "
           << "with a key less than 4." << endl;
   else
      cout << "The element of hash_multimap hm1 with a key >= 40 is: "
           << p1.first -> first << "." << endl;
}
The lower bound of the element with a key of 2
in the hash_multimap hm1 is: 20.
The upper bound of the element with a key of 2
in the hash_multimap hm1 is: 30.
A direct call of upper_bound( 2 ) gives 30,
matching the 2nd element of the pair returned by equal_range( 2 ).
The hash_multimap hm1 doesn't have an element with a key less than 4.

hash_multimap::erase

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Bir hash_multimap içindeki bir öğeyi veya öğe aralığını belirtilen konumlardan kaldırır veya belirtilen bir anahtarla eşleşen öğeleri kaldırır.

iterator erase(iterator _Where);

iterator erase(iterator first, iterator last);

size_type erase(const key_type& key);

Parametreler

_Nerede
hash_multimap kaldırılacak öğenin konumu.

birinci
hash_multimap kaldırılan ilk öğenin konumu.

son
hash_multimap kaldırılan son öğenin hemen ötesinde konum.

anahtar
hash_multimap kaldırılacak öğelerin anahtarı.

Dönüş Değeri

İlk iki üye işlevi için, kaldırılan öğelerin ötesinde kalan ilk öğeyi belirten çift yönlü bir yineleyici veya böyle bir öğe yoksa hash_multimap sonuna yönelik bir işaretçi.

Üçüncü üye işlevi için, hash_multimap kaldırılan öğe sayısını döndürür.

Açıklamalar

Üye işlevleri hiçbir zaman özel durum oluşturmaz.

Örnek

Aşağıdaki örnekte hash_multimap::erase üye işlevinin kullanımı gösterilmektedir.

// hash_multimap_erase.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main()
{
    using namespace std;
    using namespace stdext;
    hash_multimap<int, int> hm1, hm2, hm3;
    hash_multimap<int, int> :: iterator pIter, Iter1, Iter2;
    int i;
    hash_multimap<int, int>::size_type n;
    typedef pair<int, int> Int_Pair;

    for (i = 1; i < 5; i++)
    {
        hm1.insert(Int_Pair (i, i) );
        hm2.insert(Int_Pair (i, i*i) );
        hm3.insert(Int_Pair (i, i-1) );
    }

    // The 1st member function removes an element at a given position
    Iter1 = ++hm1.begin();
    hm1.erase(Iter1);

    cout << "After the 2nd element is deleted, "
         << "the hash_multimap hm1 is:";
    for (pIter = hm1.begin(); pIter != hm1.end(); pIter++)
        cout << " " << pIter -> second;
    cout << "." << endl;

    // The 2nd member function removes elements
    // in the range [ first,  last)
    Iter1 = ++hm2.begin();
    Iter2 = --hm2.end();
    hm2.erase(Iter1, Iter2);

    cout << "After the middle two elements are deleted, "
         << "the hash_multimap hm2 is:";
    for (pIter = hm2.begin(); pIter != hm2.end(); pIter++)
        cout << " " << pIter -> second;
    cout << "." << endl;

    // The 3rd member function removes elements with a given  key
    hm3.insert(Int_Pair (2, 5));
    n = hm3.erase(2);

    cout << "After the element with a key of 2 is deleted,\n"
         << "the hash_multimap hm3 is:";
    for (pIter = hm3.begin(); pIter != hm3.end(); pIter++)
        cout << " " << pIter -> second;
    cout << "." << endl;

    // The 3rd member function returns the number of elements removed
    cout << "The number of elements removed from hm3 is: "
         << n << "." << endl;

    // The dereferenced iterator can also be used to specify a key
    Iter1 = ++hm3.begin();
    hm3.erase(Iter1);

    cout << "After another element with a key equal to that of the"
         << endl;
    cout  << "2nd element is deleted, "
          << "the hash_multimap hm3 is:";
    for (pIter = hm3.begin(); pIter != hm3.end(); pIter++)
        cout << " " << pIter -> second;
    cout << "." << endl;
}
After the 2nd element is deleted, the hash_multimap hm1 is: 1 3 4.
After the middle two elements are deleted, the hash_multimap hm2 is: 1 16.
After the element with a key of 2 is deleted,
the hash_multimap hm3 is: 0 2 3.
The number of elements removed from hm3 is: 2.
After another element with a key equal to that of the
2nd element is deleted, the hash_multimap hm3 is: 0 3.

hash_multimap::find

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Hash_multimap belirtilen anahtara eşdeğer bir anahtara sahip bir öğenin ilk konumunu ele alan bir yineleyici döndürür.

iterator find(const Key& key);

const_iterator find(const Key& key) const;

Parametreler

anahtar
Aranmakta olan hash_multimap bir öğenin sıralama anahtarıyla eşleştirilecek anahtar.

Dönüş Değeri

Belirtilen anahtara sahip bir öğenin ilk konumunu veya anahtar için eşleşme bulunamazsa hash_multimap son öğeyi tamamlayan konumu ele alan bir yineleyici.

Açıklamalar

Üye işlevi, hash_multimap sıralama anahtarı equivalent karşılaştırılabilirlikten küçük bir ilişkiyi temel alan bir sıralamaya neden olan ikili koşul altındaki bağımsız değişken anahtarına yönelik bir öğeyi ele alan bir yineleyici döndürür.

değerinin dönüş değeri find bir const_iteratoröğesine atanmışsa, hash_multimap nesnesi değiştirilemez. dönüş değeri find bir iteratoröğesine atanmışsa, hash_multimap nesnesi değiştirilebilir.

Örnek

// hash_multimap_find.cpp
// compile with: /EHsc
#include <iostream>
#include <hash_map>

int main()
{
    using namespace std;
    using namespace stdext;
    hash_multimap<int, int> hm1;
    hash_multimap<int, int> :: const_iterator hm1_AcIter, hm1_RcIter;
    typedef pair<int, int> Int_Pair;

    hm1.insert(Int_Pair(1, 10));
    hm1.insert(Int_Pair(2, 20));
    hm1.insert(Int_Pair(3, 20));
    hm1.insert(Int_Pair(3, 30));

    hm1_RcIter = hm1.find(2);
    cout << "The element of hash_multimap hm1 with a key of 2 is: "
          << hm1_RcIter -> second << "." << endl;

    hm1_RcIter = hm1.find(3);
    cout << "The first element of hash_multimap hm1 with a key of 3 is: "
          << hm1_RcIter -> second << "." << endl;

    // If no match is found for the key, end() is returned
    hm1_RcIter = hm1.find(4);

    if (hm1_RcIter == hm1.end())
        cout << "The hash_multimap hm1 doesn't have an element "
             << "with a key of 4." << endl;
    else
        cout << "The element of hash_multimap hm1 with a key of 4 is: "
             << hm1_RcIter -> second << "." << endl;

    // The element at a specific location in the hash_multimap can be
    // found using a dereferenced iterator addressing the location
    hm1_AcIter = hm1.end();
    hm1_AcIter--;
    hm1_RcIter = hm1.find(hm1_AcIter -> first);
    cout << "The first element of hm1 with a key matching"
         << endl << "that of the last element is: "
         << hm1_RcIter -> second << "." << endl;

    // Note that the first element with a key equal to
    // the key of the last element is not the last element
    if (hm1_RcIter == --hm1.end())
        cout << "This is the last element of hash_multimap hm1."
             << endl;
    else
        cout << "This is not the last element of hash_multimap hm1."
             << endl;
}
The element of hash_multimap hm1 with a key of 2 is: 20.
The first element of hash_multimap hm1 with a key of 3 is: 20.
The hash_multimap hm1 doesn't have an element with a key of 4.
The first element of hm1 with a key matching
that of the last element is: 20.
This is not the last element of hash_multimap hm1.

hash_multimap::get_allocator

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

hash_multimap oluşturmak için kullanılan ayırıcı nesnesinin bir kopyasını döndürür.

Allocator get_allocator() const;

Dönüş Değeri

hash_multimap tarafından kullanılan ayırıcı.

Açıklamalar

hash_multimap sınıfı için ayırıcılar, sınıfın depolamayı nasıl yöneteceğini belirtir. C++ Standart Kitaplığı kapsayıcı sınıfları ile sağlanan varsayılan ayırıcılar çoğu programlama gereksinimi için yeterlidir. Kendi ayırıcı sınıfınızı yazmak ve kullanmak gelişmiş bir C++ konusudur.

Örnek

// hash_multimap_get_allocator.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int>::allocator_type hm1_Alloc;
   hash_multimap <int, int>::allocator_type hm2_Alloc;
   hash_multimap <int, double>::allocator_type hm3_Alloc;
   hash_multimap <int, int>::allocator_type hm4_Alloc;

   // The following lines declare objects
   // that use the default allocator.
   hash_multimap <int, int> hm1;
   hash_multimap <int, int> hm2;
   hash_multimap <int, double> hm3;

   hm1_Alloc = hm1.get_allocator( );
   hm2_Alloc = hm2.get_allocator( );
   hm3_Alloc = hm3.get_allocator( );

   cout << "The number of integers that can be allocated"
        << endl << " before free memory is exhausted: "
        << hm2.max_size( ) << "." << endl;

   cout << "The number of doubles that can be allocated"
        << endl << " before free memory is exhausted: "
        << hm3.max_size( ) <<  "." << endl;

   // The following line creates a hash_multimap hm4
   // with the allocator of hash_multimap hm1.
   hash_multimap <int, int> hm4( less<int>( ), hm1_Alloc );

   hm4_Alloc = hm4.get_allocator( );

   // Two allocators are interchangeable if
   // storage allocated from each can be
   // deallocated by the other
   if( hm1_Alloc == hm4_Alloc )
   {
      cout << "The allocators are interchangeable."
           << endl;
   }
   else
   {
      cout << "The allocators are not interchangeable."
           << endl;
   }
}

hash_multimap::hash_multimap

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Boş olan veya diğer hash_multimap tümünün veya bir bölümünün kopyası olan bir hash_multimap oluşturur.

hash_multimap();

explicit hash_multimap(
    const Compare& Comp);

hash_multimap(
    const Compare& Comp,
    const Allocator& Al);

hash_multimap(
    const hash_multimap& Right);

hash_multimap(
    hash_multimap&& Right);

hash_multimap(
    initializer_list<Type> IList);

hash_multimap(
    initializer_list<Type> IList,
    const Compare& Comp);

hash_multimap(
    initializer_list<Type> IList,
    const Compare& Comp,
    const Allocator& Al);

template <class InputIterator>
hash_multimap(
    InputIterator First,
    InputIterator Last);

template <class InputIterator>
hash_multimap(
    InputIterator First,
    InputIterator Last,
    const Compare& Comp);

template <class InputIterator>
hash_multimap(
    InputIterator First,
    InputIterator Last,
    const Compare& Comp,
    const Allocator& Al);

Parametreler

Al
Varsayılan olarak Allocatorolan bu hash_multimap nesnesi için kullanılacak depolama ayırıcı sınıfı.

Comp
Eşlemedeki öğeleri sıralamak için kullanılan ve varsayılan olarak const Traitsolarak olan karşılaştırma Traits işlevi.

Sağ
Oluşturulacak kümenin bir kopyası olduğu harita.

Birinci
Kopyalanacak öğe aralığındaki ilk öğenin konumu.

Son
Kopyalanacak öğe aralığının ötesindeki ilk öğenin konumu.

IList
Kopyalanacak initializer_list.

Açıklamalar

Tüm oluşturucular, hash_multimap için bellek depolamasını yöneten ve daha sonra get_allocator çağrılarak döndürülebilen bir tür ayırıcı nesnesi depolar. Ayırıcı parametresi genellikle sınıf bildirimlerinde atlanır ve alternatif ayırıcıların yerine önişlem makroları kullanılır.

Tüm oluşturucular hash_multimap başlatır.

Tüm oluşturucular, hash_multimap anahtarları arasında bir sıra oluşturmak için kullanılan ve daha sonra key_compTraitsdöndürülebilecek türde bir işlev nesnesi depolar.

İlk üç oluşturucu boş bir başlangıç hash_multimap belirtir; İkincisi, öğelerin sırasını oluştururken kullanılacak karşılaştırma işlevinin (Comp) türünü, üçüncüsü ise kullanılacak ayırıcı türünü (_Al) açıkça belirtir. anahtar sözcüğü explicit belirli türdeki otomatik tür dönüştürmelerini gizler.

Dördüncü oluşturucu, hash_multimap Rightbir kopyasını belirtir.

Sonraki üç oluşturucu, sınıfın First, Last) ve ayırıcının karşılaştırma işlevinin türünü belirtirken açıklığı artırarak bir eşleme aralığını Traits kopyalar.

Sekizinci oluşturucu hash_multimap Righttaşır.

Son üç oluşturucu bir initializer_list kullanır.

hash_multimap::insert

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

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

iterator insert(
    const value_type& Val);

iterator insert(
    const_iterator Where,
    const value_type& Val);void insert(
    initializer_list<value_type> IList);

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

Val
Hash_multimap eklenecek öğenin değeri, zaten bu öğeyi içermiyorsa veya daha genel olarak, anahtarı eşdeğer sıralı olan bir öğe içermiyorsa.

Nerede
Doğru ekleme noktasını aramaya nereden başlayacağına ilişkin ipucu.

Birinci
Bir eşlemeden kopyalanacak ilk öğenin konumu.

Son
Bir eşlemeden kopyalanacak son öğenin hemen ötesindeki konum.

Dönüş Değeri

İlk iki insert üye işlevi, yeni öğenin eklendiği konumu gösteren bir yineleyici döndürür.

Üçüncü üye işlevi, eklenecek öğeler için bir initializer_list kullanır.

Dördüncü üye işlevi, öğe değerlerinin sırasını belirtilen küme aralığındaki [First, Last) bir yineleyici tarafından ele alınan her öğeye karşılık gelen bir eşlem içine ekler.

Son iki insert üye işlevi, eklenen değeri taşımaları-oluşturmaları dışında ilk iki işlevle aynı şekilde davranır.

Açıklamalar

Bir öğenin value_type bir çifttir, böylece bir öğenin değeri, ilk bileşenin anahtar değerine, ikinci bileşenin ise öğenin veri değerine eşit olduğu sıralı bir çift olur.

Ekleme noktası hemen Where'uinsert, ekleme noktası logaritmik saat yerine ipucu sürümü için amorti edilmiş sabit sürede gerçekleşebilir.

hash_multimap::yineleyici

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

hash_multimap herhangi bir öğeyi okuyabilen veya değiştirebilen çift yönlü bir yineleyici sağlayan tür.

typedef list<typename Traits::value_type, typename Traits::allocator_type>::iterator iterator;

Açıklamalar

iterator hash_multimap tarafından tanımlanan, ilkişaret eder.

hash_multimap bir öğeye işaret eden adlı Iter yineleyicinin başvurularını geri almak için işlecini -> kullanın.

öğesinin anahtarının değerine erişmek için, Iter->firstile eşdeğer (*Iter).firstolan kullanın. öğesinin eşlenmiş veri kümesinin değerine erişmek için öğesine Iter->secondeşdeğer (*Iter).firstolan kullanın.

Bir öğenin değerini değiştirmek için bir tür iterator kullanılabilir.

Örnek

bildirme ve kullanma örneği için iterator örneğine bakın.

hash_multimap::key_comp

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

hash_multimap anahtarları sıralamak için kullanılan karşılaştırma nesnesinin bir kopyasını alır.

key_compare key_comp() const;

Dönüş Değeri

bir hash_multimap öğelerini sıralamak için kullandığı işlev nesnesini döndürür.

Açıklamalar

Depolanan nesne üye işlevini tanımlar

bool operator( const Key& left, const Key& right );

true left döndürür ve sıralama düzeninde buna eşit right değildir.

Örnek

// hash_multimap_key_comp.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;

   hash_multimap <int, int, hash_compare<int, less<int>>> hm1;
   hash_multimap <int, int, hash_compare<int, less<int>>
      >::key_compare kc1 = hm1.key_comp( ) ;
   bool result1 = kc1( 2, 3 ) ;
   if( result1 == true )
   {
      cout << "kc1( 2,3 ) returns value of true,\n"
           << "where kc1 is the function object of hm1.\n"
           << endl;
   }
   else
   {
      cout << "kc1( 2,3 ) returns value of false,\n"
           << "where kc1 is the function object of hm1.\n"
           << endl;
   }

   hash_multimap <int, int, hash_compare<int, greater<int>>> hm2;
   hash_multimap <int, int, hash_compare<int, greater<int>>
      >::key_compare kc2 = hm2.key_comp( );
   bool result2 = kc2( 2, 3 ) ;
   if( result2 == true )
   {
      cout << "kc2( 2,3 ) returns value of true,\n"
           << "where kc2 is the function object of hm2."
           << endl;
   }
   else
   {
      cout << "kc2( 2,3 ) returns value of false,\n"
           << "where kc2 is the function object of hm2."
           << endl;
   }
}

hash_multimap::key_compare

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

hash_multimap iki öğe göreli sırasını belirlemek için iki sıralama anahtarını karşılaştırabilen bir işlev nesnesi sağlayan bir tür.

typedef Traits key_compare;

Açıklamalar

key_compare , Traits şablon parametresinin eş anlamlısıdır.

Özellikler hakkında daha fazla bilgi için hash_multimap Sınıfı konusuna bakın.

Örnek

bildirme ve kullanma örneği için key_compare örneğine bakın.

hash_multimap::key_type

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

hash_multimap her öğesini oluşturan sıralama anahtarı nesnesini açıklayan bir tür.

typedef Key key_type;

Açıklamalar

key_type, Anahtar şablon parametresinin eş anlamlısıdır.

Anahtar hakkında daha fazla bilgi için hash_multimap Sınıfı konusunun Açıklamalar bölümüne bakın.

Örnek

bildirme ve kullanma örneği için key_compare örneğine bakın.

hash_multimap::lower_bound

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Bir hash_multimap belirtilen anahtara eşit veya daha büyük bir anahtara sahip ilk öğeye bir yineleyici döndürür.

iterator lower_bound(const Key& key);

const_iterator lower_bound(const Key& key) const;

Parametreler

anahtar
Aranmakta olan hash_multimap bir öğenin sıralama anahtarıyla karşılaştırılacak bağımsız değişken anahtarı.

Dönüş Değeri

Hash_multimap bir öğenin konumunu bağımsız değişken anahtarına eşit veya ondan büyük bir anahtarla veya anahtar için eşleşme bulunamazsa hash_multimap son öğeyi tamamlayan konumu ele alan bir yineleyici veya const_iterator.

değerinin dönüş değeri lower_bound bir const_iteratoröğesine atanmışsa, hash_multimap nesnesi değiştirilemez. dönüş değeri lower_bound bir iteratoröğesine atanmışsa, hash_multimap nesnesi değiştirilebilir.

Örnek

// hash_multimap_lower_bound.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1;
   hash_multimap <int, int> :: const_iterator hm1_AcIter,
      hm1_RcIter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 1, 10 ) );
   hm1.insert ( Int_Pair ( 2, 20 ) );
   hm1.insert ( Int_Pair ( 3, 20 ) );
   hm1.insert ( Int_Pair ( 3, 30 ) );

   hm1_RcIter = hm1.lower_bound( 2 );
   cout << "The element of hash_multimap hm1 with a key of 2 is: "
        << hm1_RcIter -> second << "." << endl;

   hm1_RcIter = hm1.lower_bound( 3 );
   cout << "The first element of hash_multimap hm1 with a key of 3 is: "
        << hm1_RcIter -> second << "." << endl;

   // If no match is found for the key, end( ) is returned
   hm1_RcIter = hm1.lower_bound( 4 );

   if ( hm1_RcIter == hm1.end( ) )
      cout << "The hash_multimap hm1 doesn't have an element "
           << "with a key of 4." << endl;
   else
      cout << "The element of hash_multimap hm1 with a key of 4 is: "
           << hm1_RcIter -> second << "." << endl;

   // The element at a specific location in the hash_multimap can be
   // found using a dereferenced iterator addressing the location
   hm1_AcIter = hm1.end( );
   hm1_AcIter--;
   hm1_RcIter = hm1.lower_bound( hm1_AcIter -> first );
   cout << "The first element of hm1 with a key matching"
        << endl << "that of the last element is: "
        << hm1_RcIter -> second << "." << endl;

   // Note that the first element with a key equal to
   // the key of the last element is not the last element
   if ( hm1_RcIter == --hm1.end( ) )
      cout << "This is the last element of hash_multimap hm1."
           << endl;
   else
      cout << "This is not the last element of hash_multimap hm1."
           << endl;
}
The element of hash_multimap hm1 with a key of 2 is: 20.
The first element of hash_multimap hm1 with a key of 3 is: 20.
The hash_multimap hm1 doesn't have an element with a key of 4.
The first element of hm1 with a key matching
that of the last element is: 20.
This is not the last element of hash_multimap hm1.

hash_multimap::mapped_type

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

bir hash_multimap depolanan veri türünü temsil eden bir tür.

typedef Type mapped_type;

Açıklamalar

mapped_type, Tür şablon parametresinin eş anlamlısıdır.

Tür hakkında daha fazla bilgi için hash_multimap Sınıfı konusuna bakın.

Örnek

bildirme ve kullanma örneği için key_type örneğine bakın.

hash_multimap::max_size

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

hash_multimap uzunluğu üst sınırını döndürür.

size_type max_size() const;

Dönüş Değeri

hash_multimap maksimum olası uzunluğu.

Örnek

// hash_multimap_max_size.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1;
   hash_multimap <int, int> :: size_type i;

   i = hm1.max_size( );
   cout << "The maximum possible length "
        << "of the hash_multimap is " << i << "." << endl;
}

hash_multimap::operator=

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

hash_multimap öğelerini başka bir hash_multimap kopyasıyla değiştirir.

hash_multimap& operator=(const hash_multimap& right);

hash_multimap& operator=(hash_multimap&& right);

Parametreler

Sağ
içine .

Açıklamalar

içindeki hash_multimapoperator= mevcut öğeleri sildikten sonra içeriğini kopyalayarak veya doğrudan içine hash_multimaptaşır.

Örnek

// hash_multimap_operator_as.cpp
// compile with: /EHsc
#include <hash_multimap>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap<int, int> v1, v2, v3;
   hash_multimap<int, int>::iterator iter;

   v1.insert(pair<int, int>(1, 10));

   cout << "v1 = " ;
   for (iter = v1.begin(); iter != v1.end(); iter++)
      cout << iter->second << " ";
   cout << endl;

   v2 = v1;
   cout << "v2 = ";
   for (iter = v2.begin(); iter != v2.end(); iter++)
      cout << iter->second << " ";
   cout << endl;

// move v1 into v2
   v2.clear();
   v2 = move(v1);
   cout << "v2 = ";
   for (iter = v2.begin(); iter != v2.end(); iter++)
      cout << iter->second << " ";
   cout << endl;
}

hash_multimap::p ointer

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

hash_multimap bir öğeye işaretçi sağlayan tür.

typedef list<typename _Traits::value_type, typename _Traits::allocator_type>::pointer pointer;

Açıklamalar

Bir öğenin değerini değiştirmek için bir tür pointer kullanılabilir.

Çoğu durumda, bir hash_multimap nesnesindeki öğelere erişmek için yineleyici kullanılmalıdır.

hash_multimap::rbegin

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Ters çevrilmiş bir hash_multimap ilk öğeyi ele alan bir yineleyici döndürür.

const_reverse_iterator rbegin() const;

reverse_iterator rbegin();

Dönüş Değeri

Ters çevrilmiş bir hash_multimap ilk öğeyi ele alan veya ters çevrilmeyen hash_multimap son öğe olan öğeyi ele alan ters çift yönlü yineleyici.

Açıklamalar

rbegin, bir hash_multimap ile begin'in kullanıldığı gibi ters çevrilmiş bir hash_multimap ile kullanılır.

değerinin dönüş değeri rbegin öğesine const_reverse_iteratoratanmışsa, hash_multimap nesnesi değiştirilemez. değerinin dönüş değeri rbegin öğesine reverse_iteratoratanmışsa, hash_multimap nesnesi değiştirilebilir.

rbegin bir hash_multimap geriye doğru yinelemek için kullanılabilir.

Örnek

// hash_multimap_rbegin.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1;

   hash_multimap <int, int> :: iterator hm1_Iter;
   hash_multimap <int, int> :: reverse_iterator hm1_rIter;
   hash_multimap <int, int> :: const_reverse_iterator hm1_crIter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 1, 10 ) );
   hm1.insert ( Int_Pair ( 2, 20 ) );
   hm1.insert ( Int_Pair ( 3, 30 ) );

   hm1_rIter = hm1.rbegin( );
   cout << "The first element of the reversed hash_multimap hm1 is "
        << hm1_rIter -> first << "." << endl;

   // begin can be used to start an iteration
   // through a hash_multimap in a forward order
   cout << "The hash_multimap is: ";
   for ( hm1_Iter = hm1.begin( ) ; hm1_Iter != hm1.end( ); hm1_Iter++)
      cout << hm1_Iter -> first << " ";
      cout << "." << endl;

   // rbegin can be used to start an iteration
   // through a hash_multimap in a reverse order
   cout << "The reversed hash_multimap is: ";
   for ( hm1_rIter = hm1.rbegin( ) ; hm1_rIter != hm1.rend( ); hm1_rIter++)
      cout << hm1_rIter -> first << " ";
      cout << "." << endl;

   // A hash_multimap element can be erased by dereferencing its key
   hm1_rIter = hm1.rbegin( );
   hm1.erase ( hm1_rIter -> first );

   hm1_rIter = hm1.rbegin( );
   cout << "After the erasure, the first element\n"
        << "in the reversed hash_multimap is "
        << hm1_rIter -> first << "." << endl;
}
The first element of the reversed hash_multimap hm1 is 3.
The hash_multimap is: 1 2 3 .
The reversed hash_multimap is: 3 2 1 .
After the erasure, the first element
in the reversed hash_multimap is 2.

hash_multimap::reference

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

bir hash_multimap depolanan bir öğeye başvuru sağlayan bir tür.

typedef list<typename _Traits::value_type, typename _Traits::allocator_type>::reference reference;

Örnek

// hash_multimap_reference.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 1, 10 ) );
   hm1.insert ( Int_Pair ( 2, 20 ) );

   // Declare and initialize a const_reference &Ref1
   // to the key of the first element
   const int &Ref1 = ( hm1.begin( ) -> first );

   // The following line would cause an error as the
   // non-const_reference cannot be used to access the key
   // int &Ref1 = ( hm1.begin( ) -> first );

   cout << "The key of first element in the hash_multimap is "
        << Ref1 << "." << endl;

   // Declare and initialize a reference &Ref2
   // to the data value of the first element
   int &Ref2 = ( hm1.begin( ) -> second );

   cout << "The data value of first element in the hash_multimap is "
        << Ref2 << "." << endl;

   //The non-const_reference can be used to modify the
   //data value of the first element
   Ref2 = Ref2 + 5;
   cout << "The modified data value of first element is "
        << Ref2 << "." << endl;
}
The key of first element in the hash_multimap is 1.
The data value of first element in the hash_multimap is 10.
The modified data value of first element is 15.

hash_multimap::rend

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Ters çevrilmiş bir hash_multimap son öğenin başarılı olduğu konumu ele alan bir yineleyici döndürür.

const_reverse_iterator rend() const;

reverse_iterator rend();

Dönüş Değeri

Ters çevrilmiş bir hash_multimap son öğeyi (ters çevrilmeyen hash_multimap ilk öğeden önce gelen konum) başarılı olan konumu ele alan ters çift yönlü yineleyici.

Açıklamalar

rendaynı ucun hash_multimap kullanıldığı gibi ters çevrilmiş hash_multimap kullanılır.

dönüş değeri rend bir const_reverse_iterator atanmışsa, hash_multimap nesnesi değiştirilemez. dönüş değeri rend bir reverse_iterator atanmışsa, hash_multimap nesnesi değiştirilebilir.

rend bir ters yineleyicinin hash_multimap sonuna ulaşıp ulaşmadığını test etmek için kullanılabilir.

tarafından rend döndürülen değer başvurulmamalıdır.

Örnek

// hash_multimap_rend.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1;

   hash_multimap <int, int> :: iterator hm1_Iter;
   hash_multimap <int, int> :: reverse_iterator hm1_rIter;
   hash_multimap <int, int> :: const_reverse_iterator hm1_crIter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 1, 10 ) );
   hm1.insert ( Int_Pair ( 2, 20 ) );
   hm1.insert ( Int_Pair ( 3, 30 ) );

   hm1_rIter = hm1.rend( );
   hm1_rIter--;
   cout << "The last element of the reversed hash_multimap hm1 is "
        << hm1_rIter -> first << "." << endl;

   // begin can be used to start an iteration
   // through a hash_multimap in a forward order
   cout << "The hash_multimap is: ";
   for ( hm1_Iter = hm1.begin( ) ; hm1_Iter != hm1.end( ); hm1_Iter++)
      cout << hm1_Iter -> first << " ";
      cout << "." << endl;

   // rbegin can be used to start an iteration
   // through a hash_multimap in a reverse order
   cout << "The reversed hash_multimap is: ";
   for ( hm1_rIter = hm1.rbegin( ) ; hm1_rIter != hm1.rend( ); hm1_rIter++)
      cout << hm1_rIter -> first << " ";
      cout << "." << endl;

   // A hash_multimap element can be erased by dereferencing its key
   hm1_rIter = --hm1.rend( );
   hm1.erase ( hm1_rIter -> first );

   hm1_rIter = hm1.rend( );
   hm1_rIter--;
   cout << "After the erasure, the last element "
        << "in the reversed hash_multimap is "
        << hm1_rIter -> first << "." << endl;
}
The last element of the reversed hash_multimap hm1 is 1.
The hash_multimap is: 1 2 3 .
The reversed hash_multimap is: 3 2 1 .
After the erasure, the last element in the reversed hash_multimap is 2.

hash_multimap::reverse_iterator

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Ters çevrilmiş bir hash_multimap bir öğeyi okuyabilen veya değiştirebilen çift yönlü bir yineleyici sağlayan tür.

typedef list<typename Traits::value_type, typename Traits::allocator_type>::reverse_iterator reverse_iterator;

Açıklamalar

Hash_multimap tersten yinelemek için bir tür reverse_iterator kullanılır.

reverse_iterator hash_multimap tarafından tanımlanan, value_type türündeki const Key, Type işaret eder. Anahtarın değeri ilk üye çifti aracılığıyla kullanılabilir ve eşlenen öğenin değeri çiftin ikinci üyesi aracılığıyla kullanılabilir.

Örnek

nasıl bildirilip örneğine bakın.

hash_multimap::size

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

hash_multimap öğe sayısını döndürür.

size_type size() const;

Dönüş Değeri

hash_multimap geçerli uzunluğu.

Örnek

Aşağıdaki örnekte hash_multimap::size üye işlevinin kullanımı gösterilmektedir.

// hash_multimap_size.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
    using namespace std;
    using namespace stdext;
    hash_multimap<int, int> hm1, hm2;
    hash_multimap<int, int>::size_type i;
    typedef pair<int, int> Int_Pair;

    hm1.insert(Int_Pair(1, 1));
    i = hm1.size();
    cout << "The hash_multimap length is " << i << "." << endl;

    hm1.insert(Int_Pair(2, 4));
    i = hm1.size();
    cout << "The hash_multimap length is now " << i << "." << endl;
}
The hash_multimap length is 1.
The hash_multimap length is now 2.

hash_multimap::size_type

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

bir hash_multimap öğe sayısını sayan işaretsiz bir tamsayı türü.

typedef list<typename _Traits::value_type, typename _Traits::allocator_type>::size_type size_type;

Örnek

Bildirme ve kullanma örneği için boyut örneğine bakın size_type

hash_multimap::swap

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

İki hash_multimaps öğelerini değiştirir.

void swap(hash_multimap& right);

Parametreler

Sağ
Değiştirilecek öğeleri veya öğeleri hash_multimap öğeleriyle değiştirilecek hash_multimap sağlayan hash_multimap.

Açıklamalar

Üye işlevi, öğeleri değiş tokuş edilen iki hash_multimaps öğeleri belirten hiçbir başvuruyu, işaretçiyi veya yineleyiciyi geçersiz kılmaz.

Örnek

// hash_multimap_swap.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1, hm2, hm3;
   hash_multimap <int, int>::iterator hm1_Iter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 1, 10 ) );
   hm1.insert ( Int_Pair ( 2, 20 ) );
   hm1.insert ( Int_Pair ( 3, 30 ) );
   hm2.insert ( Int_Pair ( 10, 100 ) );
   hm2.insert ( Int_Pair ( 20, 200 ) );
   hm3.insert ( Int_Pair ( 30, 300 ) );

   cout << "The original hash_multimap hm1 is:";
   for ( hm1_Iter = hm1.begin( ); hm1_Iter != hm1.end( ); hm1_Iter++ )
      cout << " " << hm1_Iter -> second;
   cout   << "." << endl;

   // This is the member function version of swap
   hm1.swap( hm2 );

   cout << "After swapping with hm2, hash_multimap hm1 is:";
   for ( hm1_Iter = hm1.begin( ); hm1_Iter != hm1.end( ); hm1_Iter++ )
      cout << " " << hm1_Iter -> second;
   cout  << "." << endl;

   // This is the specialized template version of swap
   swap( hm1, hm3 );

   cout << "After swapping with hm3, hash_multimap hm1 is:";
   for ( hm1_Iter = hm1.begin( ); hm1_Iter != hm1.end( ); hm1_Iter++ )
      cout << " " << hm1_Iter -> second;
   cout   << "." << endl;
}
The original hash_multimap hm1 is: 10 20 30.
After swapping with hm2, hash_multimap hm1 is: 100 200.
After swapping with hm3, hash_multimap hm1 is: 300.

hash_multimap::upper_bound

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Bir hash_multimap belirtilen anahtardan büyük bir anahtarla ilk öğeye bir yineleyici döndürür.

iterator upper_bound(const Key& key);

const_iterator upper_bound(const Key& key) const;

Parametreler

anahtar
Aranmakta olan hash_multimap bir öğenin sıralama anahtarıyla karşılaştırılacak bağımsız değişken anahtarı.

Dönüş Değeri

Hash_multimap bir öğenin konumunu bağımsız değişken anahtarından daha büyük bir anahtarla veya anahtar için eşleşme bulunamazsa hash_multimap son öğeyi tamamlayan konumu ele alan bir yineleyici veya const_iterator.

değerinin dönüş değeri upper_bound bir const_iteratoröğesine atanmışsa, hash_multimap nesnesi değiştirilemez. değerinin dönüş değeri upper_bound bir iteratoröğesine atanmışsa, hash_multimap nesnesi değiştirilebilir.

Örnek

// hash_multimap_upper_bound.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1;
   hash_multimap <int, int> :: const_iterator hm1_AcIter, hm1_RcIter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 1, 10 ) );
   hm1.insert ( Int_Pair ( 2, 20 ) );
   hm1.insert ( Int_Pair ( 3, 30 ) );
   hm1.insert ( Int_Pair ( 3, 40 ) );

   hm1_RcIter = hm1.upper_bound( 1 );
   cout << "The 1st element of hash_multimap hm1 with "
        << "a key greater than 1 is: "
        << hm1_RcIter -> second << "." << endl;

   hm1_RcIter = hm1.upper_bound( 2 );
   cout << "The first element of hash_multimap hm1\n"
        << "with a key greater than 2 is: "
        << hm1_RcIter -> second << "." << endl;

   // If no match is found for the key, end( ) is returned
   hm1_RcIter = hm1.lower_bound( 4 );

   if ( hm1_RcIter == hm1.end( ) )
      cout << "The hash_multimap hm1 doesn't have an element "
           << "with a key of 4." << endl;
   else
      cout << "The element of hash_multimap hm1 with a key of 4 is: "
           << hm1_RcIter -> second << "." << endl;

   // The element at a specific location in the hash_multimap can be
   // found using a dereferenced iterator addressing the location
   hm1_AcIter = hm1.begin( );
   hm1_RcIter = hm1.upper_bound( hm1_AcIter -> first );
   cout << "The first element of hm1 with a key greater than"
        << endl << "that of the initial element of hm1 is: "
        << hm1_RcIter -> second << "." << endl;
}
The 1st element of hash_multimap hm1 with a key greater than 1 is: 20.
The first element of hash_multimap hm1
with a key  greater than 2 is: 30.
The hash_multimap hm1 doesn't have an element with a key of 4.
The first element of hm1 with a key greater than
that of the initial element of hm1 is: 20.

hash_multimap::value_comp

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

Üye işlevi, anahtar değerlerini karşılaştırarak bir hash_multimap öğelerin sırasını belirleyen bir işlev nesnesi döndürür.

value_compare value_comp() const;

Dönüş Değeri

Bir hash_multimap öğelerini sıralamak için kullandığı karşılaştırma işlevi nesnesini döndürür.

Açıklamalar

hash_multimap Depolanan nesne üye işlevini tanımlar

bool operator( value_type& left, value_type& right);

öğesinin anahtar değeri true önceyse ve sıralama düzenindeki anahtar değerine left eşit değilse döndürürright.

Örnek

// hash_multimap_value_comp.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;

   hash_multimap <int, int, hash_compare<int, less<int>>> hm1;
   hash_multimap <int, int, hash_compare<int, less<int>>
      >::value_compare vc1 = hm1.value_comp( );
   hash_multimap <int,int>::iterator Iter1, Iter2;

   Iter1= hm1.insert ( hash_multimap <int, int> :: value_type ( 1, 10 ) );
   Iter2= hm1.insert ( hash_multimap <int, int> :: value_type ( 2, 5 ) );

   if( vc1( *Iter1, *Iter2 ) == true )
   {
      cout << "The element ( 1,10 ) precedes the element ( 2,5 )."
           << endl;
   }
   else
   {
      cout << "The element ( 1,10 ) does "
           << "not precede the element ( 2,5 )."
           << endl;
   }

   if( vc1( *Iter2, *Iter1 ) == true )
   {
      cout << "The element ( 2,5 ) precedes the element ( 1,10 )."
           << endl;
   }
   else
   {
      cout << "The element ( 2,5 ) does "
           << "not precede the element ( 1,10 )."
           << endl;
   }
}

hash_multimap::value_type

Not

Bu, API artık kullanılmıyor. Alternatif olarak sınıf unordered_multimap.

bir hash_multimap depolanan nesne türünü temsil eden bir tür.

typedef pair<const Key, Type> value_type;

Açıklamalar

value_typemapped_type, mapped_type ve key_type eşleştirmeyen sabit key_type olduğu bildirilir<, çünkü ilişkilendirilebilir kapsayıcının anahtarları, tutarsız bir yineleyici veya başvuru kullanılarak değiştirilemez.><

Örnek

// hash_multimap_value_type.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   typedef pair <const int, int> cInt2Int;
   hash_multimap <int, int> hm1;
   hash_multimap <int, int> :: key_type key1;
   hash_multimap <int, int> :: mapped_type mapped1;
   hash_multimap <int, int> :: value_type value1;
   hash_multimap <int, int> :: iterator pIter;

   // value_type can be used to pass the correct type
   // explicitly to avoid implicit type conversion
   hm1.insert ( hash_multimap <int, int> :: value_type ( 1, 10 ) );

   // Compare another way to insert objects into a hash_multimap
   hm1.insert ( cInt2Int ( 2, 20 ) );

   // Initializing key1 and mapped1
   key1 = ( hm1.begin( ) -> first );
   mapped1 = ( hm1.begin( ) -> second );

   cout << "The key of first element in the hash_multimap is "
        << key1 << "." << endl;

   cout << "The data value of first element in the hash_multimap is "
        << mapped1 << "." << endl;

   // The following line would cause an error because
   // the value_type is not assignable
   // value1 = cInt2Int ( 4, 40 );

   cout  << "The keys of the mapped elements are:";
   for ( pIter = hm1.begin( ) ; pIter != hm1.end( ) ; pIter++ )
      cout << " " << pIter -> first;
   cout << "." << endl;

   cout  << "The values of the mapped elements are:";
   for ( pIter = hm1.begin( ) ; pIter != hm1.end( ) ; pIter++ )
      cout << " " << pIter -> second;
   cout << "." << endl;
}
The key of first element in the hash_multimap is 1.
The data value of first element in the hash_multimap is 10.
The keys of the mapped elements are: 1 2.
The values of the mapped elements are: 10 20.

Ayrıca bkz.

C++ Standart Kitaplığında İş Parçacığı Güvenliği
C++ Standart Kitaplığı Başvurusu