namespace cpp {}

C++ lernen, kennen, anwenden

Benutzer-Werkzeuge

Webseiten-Werkzeuge


kennen:lib:max_element

max_element()

#include <algorithm>

For max_element (For first, For last) 
For max_element (For first, For last, Binary comp) 
For max_element (Exec pol, For first, For last) 
For max_element (Exec pol, For first, For last, Binary comp) 
 
For ranges::max_element (Range r, Binary comp = {}, Proj proj = {})
For ranges::max_element (For first, For last, Binary comp = {}, Proj proj = {})

Liefert einen Iterator auf das größte Element des Bereiches [first,last).

Parameter

first Anfang des Bereiches
last Ende des Bereiches
comp Sortierkriterium (Vorgabe = less)
proj einstelliger Funktor (Vorgabe = std::identity)
pol parallele Ausführungsart

Ergebnis

Rückgabewert: der erste Iterator i im Bereich, für den mit jedem anderen Iterator j in diesem Bereich !(*i < *j) bzw. comp(proj(*i), proj(*j)) == false gilt.

Siehe auch

Beispiel

max_element.cpp
#include <algorithm>
#include <iostream>
 
int main()
{
  double arr[] = { 3, 2, 0, 1, 5, 4 };
 
  std::cout << "Kleinster Wert: " << *std::min_element(arr, end+6) << '\n';
  std::cout << "Groesster Wert: " << *std::max_element(arr, end+6) << '\n';
}
kennen/lib/max_element.txt · Zuletzt geändert: 2020-06-15 14:14 von 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki