hash_multiset::equal_range
[!POZNÁMKA]
Toto rozhraní API je zastaralé.Alternativou je unordered_multiset – třída.
Vrátí funkce pár iterátorů první prvek v hash_multiset s klíčem, který je větší než zadaný klíč a na první prvek v hash_multiset s klíčem, který je roven nebo větší než klíč.
pair <const_iterator, const_iterator> equal_range (
const Key& _Key
) const;
pair <iterator, iterator> equal_range (
const Key& _Key
);
Parametry
- _Key
Klíč argument srovnávat s klíčem řazení prvek z hash_multiset hledání.
Vrácená hodnota
Pár iterátory, kde první je lower_bound klíče a druhý je upper_bound klíče.
První iterace dvojice přístup k pr vrácený členskou funkcí, používají pr. první a přistoupit přes ukazatel iterátor dolní mez, pomocí * (pr.první).Přístup k druhé iteraci páru pr vrácený členskou funkcí, používají pr. druhé a přistoupit přes ukazatel iterátor horní mez, pomocí * (pr.druhý).
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_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;
}
Požadavky
Záhlaví:<hash_set>
Obor názvů: stdext