std::partition_point - cppreference.com
Da cppreference.com.
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
<metanoindex/>
<tbody> </tbody>
| Elemento definito nell'header <algorithm> |
||
|
|
(1) | (dal C++11) |
Esamina il partizionato (come per std::partition) Fascia [first, last) e individua la fine della prima partizione, che è, il primo elemento che non soddisfa o p last se l'ultima se tutti gli elementi soddisfano 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.
Parametri
| first, last | - | la gamma partizionato di elementi da esaminare Original: the partitioned range of elements to examine The text has been machine-translated via Google Translate. |
| p | - | unary predicate which returns true per gli elementi che si trovano all'inizio della gamma Original: for the elements found in the beginning of the range The text has been machine-translated via Google Translate. The signature of the predicate function should be equivalent to the following:
The signature does not need to have |
| Type requirements | ||
-ForwardIt must meet the requirements of ForwardIterator.
| ||
Valore di ritorno
L'iteratore dopo la fine della prima partizione all'interno [first, last) last o se tutti gli elementi soddisfano 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.
Complessità
Logaritmica della distanza tra first e 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.
Esempio
#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
Vedi anche
controlla se un intervallo è ordinata in ordine ascendente Original: checks whether a range is sorted into ascending order The text has been machine-translated via Google Translate. (funzione di modello) [modifica] | |