hash_multiset::equal_range
[!NOTA]
Questo API è obsoleto.L'alternativa consiste unordered_multiset Class.
Restituisce una coppia degli iteratori rispettivamente al primo elemento in un hash_multiset con una chiave maggiore di una chiave specificata e il primo elemento in hash_multiset con una chiave a uguale a o maggiore della chiave.
pair <const_iterator, const_iterator> equal_range (
const Key& _Key
) const;
pair <iterator, iterator> equal_range (
const Key& _Key
);
Parametri
- _Key
La chiave dell'argomento da confrontare con la chiave di ordinamento di un elemento da hash_multiset cercato.
Valore restituito
Una coppia degli iteratori in cui il primo è lower_bound della chiave e del secondo è upper_bound chiave.
Per accedere al primo iteratore di una coppia pr restituito dalla funzione membro, utilizzare pr.primo/a e dereferenziare l'iteratore limite inferiore, utilizzare * (pr.primo/a).Per accedere al secondo iteratore di una coppia pr restituito dalla funzione membro, utilizzare pr.secondo e dereferenziare l'iteratore limite superiore, utilizzare * (pr.secondo).
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_multiset_equal_range.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
typedef hash_multiset<int> IntHSet;
IntHSet hms1;
hash_multiset <int> :: const_iterator hms1_RcIter;
hms1.insert( 10 );
hms1.insert( 20 );
hms1.insert( 30 );
pair <IntHSet::const_iterator, IntHSet::const_iterator> p1, p2;
p1 = hms1.equal_range( 20 );
cout << "The upper bound of the element with "
<< "a key of 20\nin the hash_multiset hms1 is: "
<< *(p1.second) << "." << endl;
cout << "The lower bound of the element with "
<< "a key of 20\nin the hash_multiset hms1 is: "
<< *(p1.first) << "." << endl;
// Compare the upper_bound called directly
hms1_RcIter = hms1.upper_bound( 20 );
cout << "A direct call of upper_bound( 20 ) gives "
<< *hms1_RcIter << "," << endl
<< "matching the 2nd element of the pair"
<< " returned by equal_range( 20 )." << endl;
p2 = hms1.equal_range( 40 );
// If no match is found for the key,
// both elements of the pair return end( )
if ( ( p2.first == hms1.end( ) )
&& ( p2.second == hms1.end( ) ) )
cout << "The hash_multiset hms1 doesn't have an element "
<< "with a key less than 40." << endl;
else
cout << "The element of hash_multiset hms1"
<< "with a key >= 40 is: "
<< *(p1.first) << "." << endl;
}
Requisiti
intestazione: <hash_set>
Stdext diSpazio dei nomi: