]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Algorithms/Querying Algorithms//min_element |80 |
2 | ||
3 | min_element | |
4 | =========== | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename Sequence | |
13 | , typename Pred = less<_1,_2> | |
14 | > | |
15 | struct min_element | |
16 | { | |
17 | typedef |unspecified| type; | |
18 | }; | |
19 | ||
20 | ||
21 | ||
22 | Description | |
23 | ----------- | |
24 | ||
25 | Returns an iterator to the smallest element in ``Sequence``. | |
26 | ||
27 | ||
28 | Header | |
29 | ------ | |
30 | ||
31 | .. parsed-literal:: | |
32 | ||
33 | #include <boost/mpl/min_element.hpp> | |
34 | ||
35 | ||
36 | Parameters | |
37 | ---------- | |
38 | ||
39 | +---------------+-------------------------------+-----------------------------------+ | |
40 | | Parameter | Requirement | Description | | |
41 | +===============+===============================+===================================+ | |
42 | |``Sequence`` | |Forward Sequence| | A sequence to be searched. | | |
43 | +---------------+-------------------------------+-----------------------------------+ | |
44 | | ``Pred`` | Binary |Lambda Expression| | A comparison criteria. | | |
45 | +---------------+-------------------------------+-----------------------------------+ | |
46 | ||
47 | ||
48 | Expression semantics | |
49 | -------------------- | |
50 | ||
51 | For any |Forward Sequence| ``s`` and binary |Lambda Expression| ``pred``: | |
52 | ||
53 | .. parsed-literal:: | |
54 | ||
55 | typedef min_element<s,pred>::type i; | |
56 | ||
57 | :Return type: | |
58 | |Forward Iterator|. | |
59 | ||
60 | :Semantics: | |
61 | ``i`` is the first iterator in |begin/end<s>| such that for every iterator ``j`` | |
62 | in |begin/end<s>|, | |
63 | ||
64 | .. parsed-literal:: | |
65 | ||
66 | apply< pred, deref<j>::type, deref<i>::type >::type::value == false | |
67 | ||
68 | ||
69 | ||
70 | Complexity | |
71 | ---------- | |
72 | ||
73 | Linear. Zero comparisons if ``s`` is empty, otherwise exactly ``size<s>::value - 1`` | |
74 | comparisons. | |
75 | ||
76 | ||
77 | Example | |
78 | ------- | |
79 | ||
80 | .. parsed-literal:: | |
81 | ||
82 | typedef vector<bool,char[50],long,double> types; | |
83 | typedef min_element< | |
84 | transform_view< types,sizeof_<_1> > | |
85 | >::type iter; | |
86 | ||
87 | BOOST_MPL_ASSERT(( is_same< deref<iter::base>::type, bool> )); | |
88 | ||
89 | ||
90 | See also | |
91 | -------- | |
92 | ||
93 | |Querying Algorithms|, |max_element|, |find_if|, |upper_bound|, |find| | |
94 | ||
95 | ||
96 |