]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/mpl/doc/src/refmanual/reverse_stable_partition.rst
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / reverse_stable_partition.rst
CommitLineData
7c673cae
FG
1.. Algorithms/Transformation Algorithms//reverse_stable_partition |190
2
3reverse_stable_partition
4========================
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11 template<
12 typename Seq
13 , typename Pred
14 , typename In1 = |unspecified|
15 , typename In2 = |unspecified|
16 >
17 struct reverse_stable_partition
18 {
19 typedef |unspecified| type;
20 };
21
22
23Description
24-----------
25
26Returns a pair of sequences together containing all elements in the range
27|begin/end<Seq>| split into two groups based on the predicate ``Pred``.
28``reverse_stable_partition`` is guaranteed to preserve the reversed
29relative order of the elements in the resulting sequences.
30
31
32|transformation algorithm disclaimer|
33
34
35Header
36------
37
38.. parsed-literal::
39
40 #include <boost/mpl/stable_partition.hpp>
41
42
43Model of
44--------
45
46|Reversible Algorithm|
47
48
49Parameters
50----------
51
52+-------------------+-----------------------------------+-------------------------------+
53| Parameter | Requirement | Description |
54+===================+===================================+===============================+
55| ``Seq`` | |Forward Sequence| | An original sequence. |
56+-------------------+-----------------------------------+-------------------------------+
57| ``Pred`` | Unary |Lambda Expression| | A partitioning predicate. |
58+-------------------+-----------------------------------+-------------------------------+
59| ``In1``, ``In2`` | |Inserter| | Output inserters. |
60+-------------------+-----------------------------------+-------------------------------+
61
62
63Expression semantics
64--------------------
65
66|Semantics disclaimer...| |Reversible Algorithm|.
67
68For any |Forward Sequence| ``s``, an unary |Lambda Expression| ``pred``, and |Inserter|\ s
69``in1`` and ``in2``:
70
71
72.. parsed-literal::
73
74 typedef reverse_stable_partition<s,pred,in1,in2>::type r;
75
76:Return type:
77 A |pair|.
78
79:Semantics:
80 Equivalent to
81
82 .. parsed-literal::
83
84 typedef lambda<pred>::type p;
85 typedef lambda<in1::operation>::type in1_op;
86 typedef lambda<in2::operation>::type in2_op;
87
88 typedef reverse_fold<
89 s
90 , pair< in1::state, in2::state >
91 , if_<
92 apply_wrap\ ``1``\<p,_2>
93 , pair< apply_wrap\ ``2``\<in1_op,first<_1>,_2>, second<_1> >
94 , pair< first<_1>, apply_wrap\ ``2``\<in2_op,second<_1>,_2> >
95 >
96 >::type r;
97
98
99Complexity
100----------
101
102Linear. Exactly ``size<s>::value`` applications of ``pred``, and ``size<s>::value``
103of summarized ``in1::operation`` / ``in2::operation`` applications.
104
105
106Example
107-------
108
109.. parsed-literal::
110
111 template< typename N > struct is_odd : bool_<(N::value % 2)> {};
112
113 typedef reverse_stable_partition<
114 range_c<int,0,10>
115 , is_odd<_1>
116 , back_inserter< vector<> >
117 , back_inserter< vector<> >
118 >::type r;
119
120 BOOST_MPL_ASSERT(( equal< r::first, vector_c<int,9,7,5,3,1> > ));
121 BOOST_MPL_ASSERT(( equal< r::second, vector_c<int,8,6,4,2,0> > ));
122
123
124See also
125--------
126
127|Transformation Algorithms|, |Reversible Algorithm|, |stable_partition|, |reverse_partition|, |sort|, |transform|
128
129
130