1.. Algorithms/Transformation Algorithms//partition |85 2 3partition 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 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``partition`` is a synonym for |stable_partition|. 29 30|transformation algorithm disclaimer| 31 32 33Header 34------ 35 36.. parsed-literal:: 37 38 #include <boost/mpl/partition.hpp> 39 40 41Model of 42-------- 43 44|Reversible Algorithm| 45 46 47Parameters 48---------- 49 50+-------------------+-----------------------------------+-------------------------------+ 51| Parameter | Requirement | Description | 52+===================+===================================+===============================+ 53| ``Seq`` | |Forward Sequence| | An original sequence. | 54+-------------------+-----------------------------------+-------------------------------+ 55| ``Pred`` | Unary |Lambda Expression| | A partitioning predicate. | 56+-------------------+-----------------------------------+-------------------------------+ 57| ``In1``, ``In2`` | |Inserter| | Output inserters. | 58+-------------------+-----------------------------------+-------------------------------+ 59 60 61Expression semantics 62-------------------- 63 64|Semantics disclaimer...| |Reversible Algorithm|. 65 66For any |Forward Sequence| ``s``, an unary |Lambda Expression| ``pred``, and |Inserter|\ s 67``in1`` and ``in2``: 68 69 70.. parsed-literal:: 71 72 typedef partition<s,pred,in1,in2>::type r; 73 74:Return type: 75 A |pair|. 76 77:Semantics: 78 Equivalent to 79 80 .. parsed-literal:: 81 82 typedef stable_partition<s,pred,in1,in2>::type r; 83 84 85Complexity 86---------- 87 88Linear. Exactly ``size<s>::value`` applications of ``pred``, and ``size<s>::value`` 89of summarized ``in1::operation`` / ``in2::operation`` applications. 90 91 92Example 93------- 94 95.. parsed-literal:: 96 97 template< typename N > struct is_odd : bool_<(N::value % 2)> {}; 98 99 typedef partition< 100 range_c<int,0,10> 101 , is_odd<_1> 102 , back_inserter< vector<> > 103 , back_inserter< vector<> > 104 >::type r; 105 106 BOOST_MPL_ASSERT(( equal< r::first, vector_c<int,1,3,5,7,9> > )); 107 BOOST_MPL_ASSERT(( equal< r::second, vector_c<int,0,2,4,6,8> > )); 108 109 110See also 111-------- 112 113|Transformation Algorithms|, |Reversible Algorithm|, |reverse_partition|, |stable_partition|, |sort| 114 115 116.. copyright:: Copyright � 2001-2009 Aleksey Gurtovoy and David Abrahams 117 Distributed under the Boost Software License, Version 1.0. (See accompanying 118 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 119