名前空間
変種
操作

std::stable_partition

提供: cppreference.com
< cpp‎ | algorithm

 
 
アルゴリズムライブラリ
機能します
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
シーケンス動作を非改変
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.
シーケンス動作を変更する
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.
操作を仕切る
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.
stable_partition
partition_point(C++11)
(ソートされた範囲で)ソート操作
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.
バイナリ検索操作(ソート範囲で)
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.
(ソートされた範囲で)操作を設定します
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.
ヒープ操作
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.
最小値/最大値操作
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.
数値演算
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ライブラリ
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 BidirIt, class UnaryPredicate >
BidirIt stable_partition( BidirIt first, BidirIt last, UnaryPredicate p );
並べ替えるには、そのような方法でレンジ[first, last)の要素、そのすべての要素どちらの述語p戻りtrue要素に先行するための述語p戻りfalse。要素の相対的な順序は保持されます.
Original:
Reorders the elements in the range [first, last) in such a way that all elements for which the predicate p returns true precede the elements for which predicate p returns false. Relative order of the elements is preserved.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

first, last -
順序を変更する要素の範囲
Original:
the range of elements to reorder
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
要素は他の要素の前に発注する必要があります
Original:
if the element should be ordered before other elements
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 BidirIt can be dereferenced and then implicitly converted to Type. ​

Type requirements
-
BidirIt must meet the requirements of ValueSwappable and BidirectionalIterator.
-
The type of dereferenced BidirIt must meet the requirements of MoveAssignable and MoveConstructible.

[編集] 値を返します

第二のグループの最初の要素へのイテレータ
Original:
Iterator to the first element of the second group
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 複雑

述語の、最もlast-firstスワップで正確(last-first)*log(last-first)アプリケーションまたはメモリが不足し十分なメモリがあればスワップの線形数字があっても.
Original:
Exactly last-first applications of the predicate and at most (last-first)*log(last-first) swaps if there is insufficient memory or linear number of swaps if sufficient memory is available.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

#include <iostream>
#include <algorithm>
 
int main()
{
    std::vector<int> v{0, 0, 3, 0, 2, 4, 5, 0, 7};
    std::stable_partition(v.begin(), v.end(), [](int n){return n>0;});
    for (int n : v) {
        std::cout << n << ' ';
    }
    std::cout << '\n';
}

Output:

3 2 4 5 7 0 0 0 0

[編集] も参照してください

二つのグループに要素の範囲を分割します
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.

(関数テンプレート) [edit]