hash_multiset::find
[!UWAGA]
Ten interfejs API jest nieaktualny.Alternatywą jest unordered_multiset Class.
Zwraca iterację adresowania położenie elementu w hash_multiset, klucz równoważne do określonego klucza.
iterator find(
const Key& _Key
);
const_iterator find(
const Key& _Key
) const;
Parametry
- _Key
Klucz argument mają być dopasowywane przez klucz sortowania elementu z hash_multiset, są przeszukiwane.
Wartość zwracana
Sterująca lub const_iterator że adresy lokalizacji elementu równoważne do określonego klucza lub że adresy lokalizacji sukces ostatniego elementu w hash_multiset, jeśli nie znaleziono klucza.
Uwagi
Element członkowski funkcja zwraca iteratora, która dotyczy elementu w hash_multiset, w której klucz sortowania jest równoważne do argumentu klucza pod predykatu dwuelementowego, która powoduje zamawiania oparte na mniej-niż porównywalności relacji.
Jeśli wartość zwracana przez znaleźć jest przypisany do const_iterator, nie można zmodyfikować obiektu hash_multiset.Jeśli wartość zwracana przez znaleźć jest przypisany do sterująca, można zmodyfikować obiektu hash_multiset.
W Visual C++ .NET 2003, członkowie <hash_map> i <hash_set> pliki nagłówkowe są już w przestrzeni nazw std, ale raczej zostały przeniesione do obszaru nazw stdext.Zobacz stdext nazw uzyskać więcej informacji.
Przykład
// 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;
}
Wymagania
Nagłówek: <hash_set>
Przestrzeń nazw: stdext