[ Web Proxy ]
URL:
Viewing: https://de.cppreference.com/cpp/algorithm/is_partitioned [Back]  [Original]

std::is_partitioned cppreference.com
cppreference.com
Namensrume
Varianten

std::is_partitioned

Aus cppreference.com

<metanoindex/>

 
 
Algorithm Bibliothek
Funktionen
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Nicht-modifizierende Sequenz Operationen
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.
Modifizierende Sequenz Operationen
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.
Partitionierungsoperationen
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.
Sortierung Operationen (auf sortierten Bereiche)
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.
Binary Suchaktionen (auf sortierten Bereiche)
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.
Set-Operationen (auf sortierten Bereiche)
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.
Heap-Operationen
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.
Minimum / Maximum Operationen
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.
Numerische Operationen
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-Bibliothek
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.
 
<tbody> </tbody>
definiert in Header <algorithm>
template< class InputIt, class UnaryPredicate > bool is_partitioned( InputIt first, InputIt last, UnaryPredicate p );
(seit C++11)
Versandkosten true wenn alle Elemente im Bereich [first, last) die das Prdikat erfllen p vor allen Elementen, die nicht angezeigt werden. Gibt auch true wenn [first, last) ist leer .
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.

Parameter

first, last -
das Spektrum der Elemente zu berprfen
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
fr die Elemente voraussichtlich in dem Anfang des Bereichs gefunden werden
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.

Rckgabewert

true wenn der Bereich [first, last) leer ist oder von p partitioniert. false sonst .
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.

Komplexitt

An den meisten std::distance(first, last) Anwendungen 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.

Mgliche Implementierung

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))
            return false;
    return true;
}

Beispiel

#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

Siehe auch

teilt einen Bereich von Elementen in zwei Gruppen
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.

(Funktions-Template) [edit]
locates the partition point of a partitioned range
(Funktions-Template) [edit]

Web Proxy Viewer  |  New URL  |  Original Page