hash_set::lower_bound
![]() |
---|
Этот API устарел.Альтернативы unordered_set Class. |
Возвращает итератор к первому элементу в hash_set с ключом, равно или больше, чем заданный ключ.
const_iterator lower_bound(
const Key& _Key
) const;
iterator lower_bound(
const Key& _Key
);
Параметры
- _Key
Ключ аргумента для сравнения с ключ сортировки элемента из hash_set, в котором выполняется поиск.
Возвращаемое значение
iterator или const_iterator, которое решает расположение элемента в hash_set, с ключом, равно или больше ключ аргумента или которому обращается расположение преуспевая последний элемент в hash_set если совпадение не найдено для ключа.
Заметки
В Visual C++ .NET 2003 <hash_map> элементы файлов заголовков и <hash_set> больше не находятся в пространстве имен std, но скорее перейти на пространство имен stdext.Дополнительные сведения см. в разделе Пространство имен stdext.
Пример
// 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;
}
Требования
заголовок: <hash_set>
Stdext пространство имен: