Sdílet prostřednictvím


hash_set::lower_bound

[!POZNÁMKA]

Toto rozhraní API je zastaralé.Alternativou je unordered_set Class.

Vrátí iterace první prvek hash_set s klíčem, který je roven nebo větší než zadaný klíč.

const_iterator lower_bound(
   const Key& _Key
) const;
iterator lower_bound(
   const Key& _Key
);

Parametry

  • _Key
    Argument klíč k porovnání s klíč řazení prvku z hash_set prohledávaný.

Vrácená hodnota

Iterátor nebo const_iterator , řeší umístění prvku v hash_set, že s klíčem je rovno nebo větší než argument klíč nebo který řeší umístění následných posledního prvku hash_set, pokud žádná shoda je nalezen klíč.

Poznámky

V aplikaci Visual C++ .NET 2003, členové <hash_map> a <hash_set> jsou již v oboru názvů std soubory hlaviček, ale spíše být přesunut do oboru názvů stdext.Viz stdext obor názvů Další informace.

Příklad

// 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;
}
  
  
  

Požadavky

Záhlaví: <hash_set>

Obor názvů: stdext

Viz také

Referenční dokumentace

hash_set Class

Standardní šablona knihovny