Sdílet prostřednictvím


hash_multiset::find

[!POZNÁMKA]

Toto rozhraní API je zastaralé.Alternativou je unordered_multiset – třída.

Vrátí iterace adresování umístění prvku v hash_multiset, který má klíč, který odpovídá zadaným klíčem.

iterator find( 
   const Key& _Key 
); 
const_iterator find( 
   const Key& _Key 
) const;

Parametry

  • _Key
    Klíč argument klíč řazení z hash_multiset hledání prvku odpovídat.

Vrácená hodnota

Iterátor nebo const_iterator , řeší umístění prvku odpovídá zadaný klíč nebo který řeší umístění následných poslední prvek v hash_multiset, pokud není nalezena žádná shoda pro klíč.

Poznámky

Členské funkce vrátí iterace, který řeší element v hash_multiset, jehož klíč řazení je odpovídající argument klíči binárního predikátu, která indukuje řazení založené na méně-než srovnatelnost vztah.

Pokud vrácená hodnota Najít je přiřazen const_iterator, hash_multiset objekt nelze upravit.Pokud vrácená hodnota Najít je přiřazen iterátor, hash_multiset objekt lze upravovat.

V aplikaci Visual C++ .NET 2003, členové hlavičkových souborů tříd <hash_map> a <hash_set> již nejsou v oboru názvů std, ale byly přesunuty do oboru názvů stdext.Další informace naleznete v tématu Obor názvů stdext.

Příklad

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

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multiset <int> hms1;
   hash_multiset <int> :: const_iterator hms1_AcIter, hms1_RcIter;
   
   hms1.insert( 10 );
   hms1.insert( 20 );
   hms1.insert( 30 );

   hms1_RcIter = hms1.find( 20 );
   cout << "The element of hash_multiset hms1 with a key of 20 is: "
        << *hms1_RcIter << "." << endl;

   hms1_RcIter = hms1.find( 40 );

   // If no match is found for the key, end( ) is returned
   if ( hms1_RcIter == hms1.end( ) )
      cout << "The hash_multiset hms1 doesn't have an element "
           << "with a key of 40." << endl;
   else
      cout << "The element of hash_multiset hms1 with a key of 40 is: "
           << *hms1_RcIter << "." << endl;

   // The element at a specific location in the hash_multiset can be found 
   // by using a dereferenced iterator addressing the location
   hms1_AcIter = hms1.end( );
   hms1_AcIter--;
   hms1_RcIter = hms1.find( *hms1_AcIter );
   cout << "The element of hms1 with a key matching "
        << "that of the last element is: "
        << *hms1_RcIter << "." << endl;
}
  

Požadavky

Záhlaví:<hash_set>

Obor názvů: stdext

Viz také

Referenční dokumentace

hash_multiset – třída

Standardní knihovna šablon