]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/mpl/doc/src/refmanual/reverse_unique.rst
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / reverse_unique.rst
CommitLineData
7c673cae
FG
1.. Algorithms/Transformation Algorithms//reverse_unique |180
2
3reverse_unique
4==============
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11 template<
12 typename Seq
13 , typename Pred
14 , typename In = |unspecified|
15 >
16 struct reverse_unique
17 {
18 typedef |unspecified| type;
19 };
20
21
22Description
23-----------
24
25Returns a sequence of the initial elements of every subrange of the
26reversed original sequence ``Seq`` whose elements are all the same.
27
28|transformation algorithm disclaimer|
29
30Header
31------
32
33.. parsed-literal::
34
35 #include <boost/mpl/unique.hpp>
36
37
38Model of
39--------
40
41|Reversible Algorithm|
42
43
44Parameters
45----------
46
47+---------------+-----------------------------------+-------------------------------+
48| Parameter | Requirement | Description |
49+===============+===================================+===============================+
50| ``Sequence`` | |Forward Sequence| | An original sequence. |
51+---------------+-----------------------------------+-------------------------------+
52| ``Pred`` | Binary |Lambda Expression| | An equivalence relation. |
53+---------------+-----------------------------------+-------------------------------+
54| ``In`` | |Inserter| | An inserter. |
55+---------------+-----------------------------------+-------------------------------+
56
57
58Expression semantics
59--------------------
60
61|Semantics disclaimer...| |Reversible Algorithm|.
62
63For any |Forward Sequence| ``s``, a binary |Lambda Expression| ``pred``,
64and an |Inserter| ``in``:
65
66
67.. parsed-literal::
68
69 typedef reverse_unique<s,pred,in>::type r;
70
71:Return type:
72 A type.
73
74:Semantics:
75 If ``size<s>::value <= 1``, then equivalent to
76
77 .. parsed-literal::
78
79 typedef reverse_copy<s,in>::type r;
80
81 otherwise equivalent to
82
83 .. parsed-literal::
84
85 typedef lambda<pred>::type p;
86 typedef lambda<in::operation>::type in_op;
87 typedef apply_wrap\ ``2``\<
88 in_op
89 , in::state
90 , front<types>::type
91 >::type in_state;
92
93 typedef reverse_fold<
94 s
95 , pair< in_state, front<s>::type >
96 , eval_if<
97 apply_wrap\ ``2``\<p, second<_1>, _2>
98 , identity< first<_1> >
99 , apply_wrap\ ``2``\<in_op, first<_1>, _2>
100 >
101 >::type::first r;
102
103
104Complexity
105----------
106
107Linear. Performs exactly ``size<s>::value - 1`` applications of ``pred``, and at
108most ``size<s>::value`` insertions.
109
110
111Example
112-------
113
114.. parsed-literal::
115
116 typedef vector<int,float,float,char,int,int,int,double> types;
117 typedef vector<double,int,char,float,int> expected;
118 typedef reverse_unique< types, is_same<_1,_2> >::type result;
119
120 BOOST_MPL_ASSERT(( equal< result,expected > ));
121
122
123See also
124--------
125
126|Transformation Algorithms|, |Reversible Algorithm|, |unique|, |reverse_remove|,
127|reverse_copy_if|, |replace_if|
128
129
130