std::partition_point
Aus cppreference.com
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
definiert in Header <algorithm>
|
||
template< class ForwardIt, class UnaryPredicate > ForwardIt partition_point( ForwardIt first, ForwardIt last, UnaryPredicate p); |
(1) | (seit C++11) |
Untersucht die partitioniert (wie von std::partition) Bereich
[first, last)
und findet das Ende der ersten Partition, das ist das erste Element, das nicht erfüllt p
oder last
wenn die letzte, wenn alle Elemente zu befriedigen p
.Original:
Examines the partitioned (as if by std::partition) range
[first, last)
and locates the end of the first partition, that is, the first element that does not satisfy p
or last
if last if all elements satisfy p
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Inhaltsverzeichnis |
[Bearbeiten] Parameter
first, last | - | die partitionierte Bereich von Elementen zu untersuchen
Original: the partitioned range of elements to examine The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
p | - | unary predicate which returns true für die Elemente in den Anfang des Bereichs gefunden . Original: for the elements found in the beginning of the range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. The signature of the predicate function should be equivalent to the following: bool pred(const Type &a); The signature does not need to have const &, but the function must not modify the objects passed to it. |
Type requirements | ||
-ForwardIt must meet the requirements of ForwardIterator .
|
[Bearbeiten] Rückgabewert
Der Iterator über das Ende der ersten Partition innerhalb
[first, last)
oder last
wenn alle Elemente zu befriedigen p
.Original:
The iterator past the end of the first partition within
[first, last)
or last
if all elements satisfy p
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[Bearbeiten] Komplexität
Logarithmisch im Abstand zwischen
first
und last
Original:
Logarithmic in the distance between
first
and last
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[Bearbeiten] Beispiel
#include <algorithm> #include <array> #include <iostream> #include <iterator> int main() { std::array<int, 9> v = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; auto is_even = [](int i){ return i % 2 == 0; }; std::partition(v.begin(), v.end(), is_even); auto p = std::partition_point(v.begin(), v.end(), is_even); std::cout << "Before partition:\n "; std::copy(v.begin(), p, std::ostream_iterator<int>(std::cout, " ")); std::cout << "\nAfter partition:\n "; std::copy(p, v.end(), std::ostream_iterator<int>(std::cout, " ")); }
Output:
Before partition: 8 2 6 4 After partition: 5 3 7 1 9
[Bearbeiten] Siehe auch
(C++11) |
prüft, ob ein Bereich ist in aufsteigender Reihenfolge sortiert Original: checks whether a range is sorted into ascending order The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (Funktions-Template) |