The Wayback Machine - https://web.archive.org/web/20180209035026/http://es.cppreference.com:80/w/cpp/algorithm/is_partitioned
Espacios de nombres
Variantes
Acciones

std::is_partitioned

De cppreference.com
< cpp‎ | algorithm

 
 
Algoritmo biblioteca
Funciones
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Para no modificar la secuencia de las operaciones
Original:
Non-modifying sequence operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Modificación de la secuencia de operaciones
Original:
Modifying sequence operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Particionamiento operaciones
Original:
Partitioning operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
is_partitioned(C++11)
partition
partition_copy(C++11)
Clasificación de las operaciones (en rangos ordenados)
Original:
Sorting operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Las operaciones binarias de búsqueda (en rangos ordenados)
Original:
Binary search operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conjunto de operaciones (en rangos ordenados)
Original:
Set operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Operaciones del montón
Original:
Heap operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Mínimo / máximo de operaciones
Original:
Minimum/maximum operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Operaciones numéricas
Original:
Numeric operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
C biblioteca
Original:
C library
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
Defined in header <algorithm>
template<class InputIt, class UnaryPredicate >
bool is_partitioned( InputIt first, InputIt last, UnaryPredicate p );
(desde C++11)
Devoluciones true si todos los elementos de la [first, last) rango que satisfacen el predicado p comparecer ante todos los elementos que no lo hacen. También regresa true[first, last) si está vacío .
Original:
Returns true if all elements in the range [first, last) that satisfy the predicate p appear before all elements that don't. Also returns true if [first, last) is empty.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Contenido

[editar]Parámetros

first, last -
la gama de elementos a comprobar
Original:
the range of elements to check
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
para los elementos que se espera encontrar en el comienzo de la gama
Original:
for the elements expected to be 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.
The type Type must be such that an object of type InputIt can be dereferenced and then implicitly converted to Type. ​

Type requirements
-
InputIt must meet the requirements of InputIterator.

[editar]Valor de retorno

true si el [first, last) gama está vacío o se divide por p. false de otra manera .
Original:
true if the range [first, last) is empty or is partitioned by p. false otherwise.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Complejidad

En la mayoría de aplicaciones de std::distance(first, last)p .
Original:
At most std::distance(first, last) applications of p.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Posible implementación

template<class InputIt, class UnaryPredicate >bool is_partitioned(InputIt first, InputIt last, UnaryPredicate p){for(; first != last;++first)if(!p(*first))break;for(; first != last;++first)if(p(*first))returnfalse;returntrue;}

[editar]Ejemplo

#include <algorithm>#include <array>#include <iostream>   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::cout.setf(std::ios_base::boolalpha);std::cout<< std::is_partitioned(v.begin(), v.end(), is_even)<<' ';   std::partition(v.begin(), v.end(), is_even);std::cout<< std::is_partitioned(v.begin(), v.end(), is_even)<<' ';   std::reverse(v.begin(), v.end());std::cout<< std::is_partitioned(v.begin(), v.end(), is_even);}

Output:

false true false

[editar]Ver también

divide una serie de elementos en dos grupos
Original:
divides a range of elements into two groups
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(función de plantilla)[edit]
locates the partition point of a partitioned range
(función de plantilla)[edit]
close