Sdílet prostřednictvím


hash_set::find

[!POZNÁMKA]

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

Vrátí iterace adresování umístění prvku v hash_set, obsahující zadaný klíč odpovídající klíč.

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

Parametry

  • _Key
    Argument klíč klíč řazení z hash_set prohledávaný prvku odpovídat.

Vrácená hodnota

Iterátor nebo const_iterator , adresy umístění prvku ekvivalentní klávesa nebo který řeší umístění následných posledního prvku hash_set, pokud je nalezena žádná shoda klíče.

Poznámky

Členské funkce vrátí iterátor, který řeší element v hash_set, jehož klíč řazení je rovnocenné argument klíči binárního predikátu, která indukuje řazení na základě méně-než srovnatelnosti vztah.

Pokud vrácená hodnota Najít je přiřazen const_iterator, hash_set objekt nelze upravit.Pokud vrácená hodnota Najít je přiřazen iterátor, hash_set objektu lze změnit.

V aplikaci Visual C++ .NET 2003, členové <hash_map> a <hash_set> jsou již v oboru názvů std soubory hlaviček, ale spíše být přesunut do oboru názvů stdext.Viz stdext obor názvů Další informace.

Příklad

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

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_set <int> hs1;
   hash_set <int> :: const_iterator hs1_AcIter, hs1_RcIter;
   
   hs1.insert( 10 );
   hs1.insert( 20 );
   hs1.insert( 30 );

   hs1_RcIter = hs1.find( 20 );
   cout << "The element of hash_set hs1 with a key of 20 is: "
        << *hs1_RcIter << "." << endl;

   hs1_RcIter = hs1.find( 40 );

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

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

Požadavky

Záhlaví: <hash_set>

Obor názvů: stdext

Viz také

Referenční dokumentace

hash_set Class

Standardní šablona knihovny