hash_set::lower_bound
[!NOTA]
Questo API è obsoleto.L'alternativa consiste unordered_set Class.
Restituisce un iteratore il primo elemento in un hash_set con una chiave a cui è uguale o superiore alla chiave specificata.
const_iterator lower_bound(
const Key& _Key
) const;
iterator lower_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 o 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_lower_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.lower_bound( 20 );
cout << "The element of hash_set hs1 with a key of 20 is: "
<< *hs1_RcIter << "." << endl;
hs1_RcIter = hs1.lower_bound( 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;
// An element at a specific location in the hash_set can be found
// by using a dereferenced iterator that addresses the location
hs1_AcIter = hs1.end( );
hs1_AcIter--;
hs1_RcIter = hs1.lower_bound( *hs1_AcIter );
cout << "The element of hs1 with a key matching "
<< "that of the last element is: "
<< *hs1_RcIter << "." << endl;
}
Requisiti
intestazione: <hash_set>
Stdext diSpazio dei nomi: