hash_multiset::upper_bound
[!POZNÁMKA]
Toto rozhraní API je zastaralé.Alternativou je unordered_multiset – třída.
Vrátí iterace na první prvek v hash_multiset s klíčem, který je větší než zadaný klíč.
const_iterator upper_bound(
const Key& _Key
) const;
iterator upper_bound(
const Key& _Key
);
Parametry
- _Key
Klíč argument srovnávat s klíčem řazení prvek z hash_multiset hledání.
Vrácená hodnota
Iterátor nebo const_iterator , řeší umístění první prvek hash_multiset větší než klíč argument klíčem nebo který řeší umístění následných poslední prvek v hash_multiset, pokud není nalezena žádná shoda pro klíč.
Poznámky
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_upper_bound.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.upper_bound( 20 );
cout << "The first element of hash_multiset hms1" << endl
<< " with a key greater than 20 is: "
<< *hms1_RcIter << "." << endl;
hms1_RcIter = hms1.upper_bound( 30 );
// 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 "
<< "\n with a key greater than 30." << endl;
else
cout << "The element of hash_multiset hms1"
<< "with a key > 40 is: "
<< *hms1_RcIter << "." << endl;
// An element at a specific location in the hash_multiset can be
// found by using a dereferenced iterator addressing the location
hms1_AcIter = hms1.begin( );
hms1_RcIter = hms1.upper_bound( *hms1_AcIter );
cout << "The first element of hms1\n with a key greater than "
<< endl << "that of the initial element of hms1 is: "
<< *hms1_RcIter << "." << endl;
}
Požadavky
Záhlaví:<hash_set>
Obor názvů: stdext