namespace cpp {}

C++ lernen, kennen, anwenden

Benutzer-Werkzeuge

Webseiten-Werkzeuge


Action disabled: source
kennen:lib:lower_bound

lower_bound()

#include <algorithm>

For lower_bound (For first, For last, T wert) 
For lower_bound (For first, For last, T wert, Binary comp) 
 
For ranges::lower_bound (Range r, T wert, Binary comp = {}, Proj proj = {}) 
For ranges::lower_bound (For first, For last, T wert, Binary comp = {}, Proj proj = {}) 

Bestimmt die erste Position, an der wert eingefügt werden kann, ohne die aufsteigende Ordnung der Folge [first,last) zu zerstören.

Parameter

first Anfang des Bereiches
last Ende des Bereiches
wert gesuchter Wert
comp Sortierkriterium (Vorgabe = less)
proj einstelliger Funktor (Vorgabe = std::identity)

Ergebnis

Rückgabewert: linke Grenze i des Teilbereiches, in dem wert eingefügt werden kann, ohne die Sortierung zu zerstören. Für alle Iteratoren j aus [first, i) gilt:

 comp(proj(*j), wert) == true

Siehe auch

Beispiel

lower_bound.cpp
#include <algorithm>
#include <iostream>
#include <string>
 
int main()
{
  std::string s = "abcddddefgh";
 
  std::cout << s << '\n'
            << "   "    << lower_bound(begin(s), end(s), 'd') << '\n';
            << "   ^^^" << upper_bound(begin(s), end(s), 'd') << '\n';
}
kennen/lib/lower_bound.txt · Zuletzt geändert: 2020-06-15 14:10 von 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki