]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Algorithms/Transformation Algorithms//reverse_remove_if |170 |
2 | ||
3 | reverse_remove_if | |
4 | ================= | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename Sequence | |
13 | , typename Pred | |
14 | , typename In = |unspecified| | |
15 | > | |
16 | struct reverse_remove_if | |
17 | { | |
18 | typedef |unspecified| type; | |
19 | }; | |
20 | ||
21 | ||
22 | Description | |
23 | ----------- | |
24 | ||
25 | Returns a new sequence that contains all the elements from |begin/end<Sequence>| range | |
26 | in reverse order except those that satisfy the predicate ``Pred``. | |
27 | ||
28 | |transformation algorithm disclaimer| | |
29 | ||
30 | Header | |
31 | ------ | |
32 | ||
33 | .. parsed-literal:: | |
34 | ||
35 | #include <boost/mpl/remove_if.hpp> | |
36 | ||
37 | ||
38 | Model of | |
39 | -------- | |
40 | ||
41 | |Reversible Algorithm| | |
42 | ||
43 | ||
44 | Parameters | |
45 | ---------- | |
46 | ||
47 | +---------------+-----------------------------------+-------------------------------+ | |
48 | | Parameter | Requirement | Description | | |
49 | +===============+===================================+===============================+ | |
50 | | ``Sequence`` | |Forward Sequence| | An original sequence. | | |
51 | +---------------+-----------------------------------+-------------------------------+ | |
52 | | ``Pred`` | Unary |Lambda Expression| | A removal condition. | | |
53 | +---------------+-----------------------------------+-------------------------------+ | |
54 | | ``In`` | |Inserter| | An inserter. | | |
55 | +---------------+-----------------------------------+-------------------------------+ | |
56 | ||
57 | ||
58 | Expression semantics | |
59 | -------------------- | |
60 | ||
61 | |Semantics disclaimer...| |Reversible Algorithm|. | |
62 | ||
63 | For any |Forward Sequence| ``s``, and an |Inserter| ``in``, and an unary | |
64 | |Lambda Expression| ``pred``: | |
65 | ||
66 | ||
67 | .. parsed-literal:: | |
68 | ||
69 | typedef reverse_remove_if<s,pred,in>::type r; | |
70 | ||
71 | :Return type: | |
72 | A type. | |
73 | ||
74 | :Semantics: | |
75 | Equivalent to | |
76 | ||
77 | .. parsed-literal:: | |
78 | ||
79 | typedef lambda<pred>::type p; | |
80 | typedef lambda<in::operation>::type op; | |
81 | ||
82 | typedef reverse_fold< | |
83 | s | |
84 | , in::state | |
85 | , eval_if< | |
86 | apply_wrap\ ``1``\<p,_2> | |
87 | , identity<_1> | |
88 | , apply_wrap\ ``2``\<op,_1,_2> | |
89 | > | |
90 | >::type r; | |
91 | ||
92 | ||
93 | Complexity | |
94 | ---------- | |
95 | ||
96 | Linear. Performs exactly ``size<s>::value`` applications of ``pred``, and at | |
97 | most ``size<s>::value`` insertions. | |
98 | ||
99 | ||
100 | Example | |
101 | ------- | |
102 | ||
103 | .. parsed-literal:: | |
104 | ||
105 | typedef vector_c<int,1,4,5,2,7,5,3,5>::type numbers; | |
106 | typedef reverse_remove_if< numbers, greater<_,int_<4> > >::type result; | |
107 | ||
108 | BOOST_MPL_ASSERT(( equal< result,vector_c<int,3,2,4,1>,equal_to<_,_> > )); | |
109 | ||
110 | ||
111 | See also | |
112 | -------- | |
113 | ||
114 | |Transformation Algorithms|, |Reversible Algorithm|, |remove_if|, |reverse_remove|, | |
115 | |reverse_copy_if|, |replace_if| | |
116 | ||
117 | ||
118 |