hash_set::upper_bound
[!NOTA]
Questo API è obsoleto.L'alternativa consiste unordered_set Class.
Restituisce un iteratore il primo elemento in un hash_set che con una chiave che è superiore alla chiave specificata.
const_iterator upper_bound(
const Key& _Key
) const;
iterator upper_bound(
const Key& _Key
);
Parametri
- _Key
La chiave dell'argomento da confrontare con la chiave di ordinamento di un elemento da hash_set cercato.
Valore restituito
iterator o const_iterator destinato alla posizione di un elemento in un hash_set che con una chiave a uguale a o maggiore della chiave dell'argomento, a cui è destinato alla posizione che è l'ultimo elemento a hash_set se non viene rilevata alcuna corrispondenza della chiave.
Note
In Visual C++ .NET 2003, i membri dei file di intestazione <hash_set> e <hash_map> non sono più nello spazio dei nomi di deviazione standard, ma sono stati spostati nello spazio dei nomi di stdext.Per ulteriori informazioni, vedere lo spazio dei nomi stdext.
Esempio
// hash_set_upper_bound.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.upper_bound( 20 );
cout << "The first element of hash_set hs1 with a key greater "
<< "than 20 is: " << *hs1_RcIter << "." << endl;
hs1_RcIter = hs1.upper_bound( 30 );
// 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 greater than 30." << endl;
else
cout << "The element of hash_set hs1 with a key > 40 is: "
<< *hs1_RcIter << "." << endl;
// An element at a specific location in the hash_set can be found
// by using a dereferenced iterator addressing the location
hs1_AcIter = hs1.begin( );
hs1_RcIter = hs1.upper_bound( *hs1_AcIter );
cout << "The first element of hs1 with a key greater than "
<< endl << "that of the initial element of hs1 is: "
<< *hs1_RcIter << "." << endl;
}
Requisiti
intestazione: <hash_set>
Stdext diSpazio dei nomi: