kennen:lib:lexicographical_compare
Inhaltsverzeichnis
lexicographical_compare()
#include <algorithm>
bool lexicographical_compare (In first, In last, In2 first2, In2 last2) bool lexicographical_compare (In first, In last, In2 first2, In2 last2, Binary comp) bool lexicographical_compare (Exec pol, In first, In last, In2 first2, In2 last2) bool lexicographical_compare (Exec pol, In first, In last, In2 first2, In2 last2, Binary comp) bool ranges::lexicographical_compare (Range1 r1, Range2 r2, Binary comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) bool ranges::lexicographical_compare (In first, In last, In2 first2, In2 last2, Binary comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {})
Ist wahr, wenn der Bereich [first,last) lexikographisch vor [first2,last2) einzuordnen ist.
Parameter
first | Anfang eines Bereiches |
last | Ende eines Bereiches |
first2 | Anfang des zweiten Bereiches |
last2 | Ende des zweiten Bereiches |
comp | Sortierkriterium (Vorgabe = less) |
proj | einstelliger Funktor (Vorgabe = std::identity) |
pol | parallele Ausführungsart |
Ergebnis
Rückgabewert: true, wenn bei evtl. gleichen Anfangselementen
- der erste Bereich kürzer ist als der zweite oder
- beim ersten Unterschied das Element des ersten Bereiches kleiner ist
als das entsprechende Element des zweiten Bereiches.
Andernfalls ist das Ergebnis false,
insbesondere auch bei übereinstimmenden Folgen gleicher Länge.
Siehe auch
-
Beispiel
- lexicographical_compare.cpp
#include <algorithm> #include <string> #include <iostream> int main() { std::string s, t; std::cout << "Gib zwei Worte ein: "; std::cin >> s >> t; if (std::lexicographical_compare(begin(s), end(s), begin(t), end(t))) { std::cout << s << "steht vor " << t << " im Lexikon.\n"; } else { std::cout << s << "steht nicht vor " << t << " im Lexikon.\n"; } }
kennen/lib/lexicographical_compare.txt · Zuletzt geändert: von 127.0.0.1
