add doc: min_element, max_element, minmax_element

This commit is contained in:
Bolero-MURAKAMI 2013-08-24 13:14:37 +09:00
parent 1320b41d88
commit 29babfce4e
22 changed files with 832 additions and 13 deletions

View file

@ -42,6 +42,9 @@ Sprout.Algorithm
min
max
minmax
min_element
max_element
minmax_element
.. _sprout-algorithm-non_modifying:
*******************************************************************************

View file

@ -70,7 +70,7 @@ Remarks
========================================
| Returns a copy of the leftmost argument when several arguments are equivalent to the largest.
| If an implementation not support C++14 initializer_list (SPROUT_NO_CXX14_INITIALIZER_LIST defined), then this function is not specified constexpr.
| If an implementation not support C++14 initializer_list (``SPROUT_NO_CXX14_INITIALIZER_LIST`` defined), then this function is not specified constexpr.
Complexity
========================================

View file

@ -0,0 +1,49 @@
.. _sprout-algorithm-max_element:
###############################################################################
max_element
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator>
inline SPROUT_CONSTEXPR ForwardIterator
max_element(ForwardIterator first, ForwardIterator last);
template<typename ForwardIterator, typename Compare>
inline SPROUT_CONSTEXPR ForwardIterator
max_element(ForwardIterator first, ForwardIterator last, Compare comp);
Returns
========================================
| The first iterator i in the range [first,last) such that for any iterator j in the range [first,last) the following corresponding conditions hold: ``!(*i < *j)`` or ``!comp(*i, *j)``.
| Returns last if ``first == last``.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/max_element.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::max_element(begin(input), end(input));
static_assert(*result == 10, "a min element is 10.");
static_assert(result - begin(input) == 9, "a min element position is 9.");
Complexity
========================================
| Exactly ``max((last - first) - 1, 0)`` applications of the corresponding comparisons.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/max_element.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -70,7 +70,7 @@ Remarks
========================================
| Returns a copy of the leftmost argument when several arguments are equivalent to the smallest.
| If an implementation not support C++14 initializer_list (SPROUT_NO_CXX14_INITIALIZER_LIST defined), then this function is not specified constexpr.
| If an implementation not support C++14 initializer_list (``SPROUT_NO_CXX14_INITIALIZER_LIST`` defined), then this function is not specified constexpr.
Complexity
========================================

View file

@ -0,0 +1,49 @@
.. _sprout-algorithm-min_element:
###############################################################################
min_element
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator>
inline SPROUT_CONSTEXPR ForwardIterator
min_element(ForwardIterator first, ForwardIterator last);
template<typename ForwardIterator, typename Compare>
inline SPROUT_CONSTEXPR ForwardIterator
min_element(ForwardIterator first, ForwardIterator last, Compare comp);
Returns
========================================
| The first iterator i in the range [first,last) such that for any iterator j in the range [first,last) the following corresponding conditions hold: ``!(*j < *i)`` or ``!comp(*j, *i)``.
| Returns last if ``first == last``.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/min_element.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::min_element(begin(input), end(input));
static_assert(*result == 1, "a min element is 1.");
static_assert(result - begin(input) == 0, "a min element position is 0.");
Complexity
========================================
| Exactly ``max((last - first) - 1, 0)`` applications of the corresponding comparisons.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/min_element.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -80,7 +80,7 @@ Remarks
| x is a copy of the leftmost argument when several arguments are equivalent to the smallest.
| y is a copy of the rightmost argument when several arguments are equivalent to the largest.
| If an implementation not support C++14 initializer_list (SPROUT_NO_CXX14_INITIALIZER_LIST defined), then this function is not specified constexpr.
| If an implementation not support C++14 initializer_list (``SPROUT_NO_CXX14_INITIALIZER_LIST`` defined), then this function is not specified constexpr.
Complexity
========================================

View file

@ -0,0 +1,50 @@
.. _sprout-algorithm-minmax_element:
###############################################################################
minmax_element
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator>
inline SPROUT_CONSTEXPR sprout::pair<ForwardIterator, ForwardIterator>
minmax_element(ForwardIterator first, ForwardIterator last);
template<typename ForwardIterator, typename Compare>
inline SPROUT_CONSTEXPR sprout::pair<ForwardIterator, ForwardIterator>
minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
Returns
========================================
| ``make_pair(first, first)`` if [first,last) is empty, otherwise ``make_pair(m, M)``, where m is the first iterator in [first,last) such that no iterator in the range refers to a smaller element, and where M is the last iterator in [first,last) such that no iterator in the range refers to a larger element.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/minmax_element.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::minmax_element(begin(input), end(input));
static_assert(*result.first == 1, "a min element is 1.");
static_assert(*result.second == 10, "a max element is 10.");
static_assert(result.first - begin(input) == 0, "a min element position is 0.");
static_assert(result.second - begin(input) == 9, "a max element position is 9.");
Complexity
========================================
| At most ``max(floor((3/2)*(N - 1)), 0)`` applications of the corresponding predicate, where N is ``distance(first, last)``.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/minmax_element.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -108,9 +108,9 @@
<li><a class="reference external" href="min.html"><em>min</em></a></li>
<li><a class="reference external" href="max.html"><em>max</em></a></li>
<li><a class="reference external" href="minmax.html"><em>minmax</em></a></li>
<li><tt class="xref docutils literal"><span class="pre">min_element</span></tt></li>
<li><tt class="xref docutils literal"><span class="pre">max_element</span></tt></li>
<li><tt class="xref docutils literal"><span class="pre">minmax_element</span></tt></li>
<li><a class="reference external" href="min_element.html"><em>min_element</em></a></li>
<li><a class="reference external" href="max_element.html"><em>max_element</em></a></li>
<li><a class="reference external" href="minmax_element.html"><em>minmax_element</em></a></li>
</ul>
</div>
<div class="section" id="lexicographical-comparison">

View file

@ -122,7 +122,7 @@
<h2>Remarks<a class="headerlink" href="#id4" title="Permalink to this headline"></a></h2>
<div class="line-block">
<div class="line">Returns a copy of the leftmost argument when several arguments are equivalent to the largest.</div>
<div class="line">If an implementation not support C++14 initializer_list (SPROUT_NO_CXX14_INITIALIZER_LIST defined), then this function is not specified constexpr.</div>
<div class="line">If an implementation not support C++14 initializer_list (<tt class="docutils literal"><span class="pre">SPROUT_NO_CXX14_INITIALIZER_LIST</span></tt> defined), then this function is not specified constexpr.</div>
</div>
</div>
<div class="section" id="complexity">

View file

@ -0,0 +1,172 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>max_element &mdash; Sprout v1.0 documentation</title>
<link rel="stylesheet" href="../../../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../../',
VERSION: '1.0',
COLLAPSE_MODINDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../../../_static/jquery.js"></script>
<script type="text/javascript" src="../../../_static/doctools.js"></script>
<link rel="top" title="Sprout v1.0 documentation" href="../../../index.html" />
<link rel="up" title="Sprout.Algorithm" href="index.html" />
<link rel="next" title="minmax_element" href="minmax_element.html" />
<link rel="prev" title="min_element" href="min_element.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="minmax_element.html" title="minmax_element"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="min_element.html" title="min_element"
accesskey="P">previous</a> |</li>
<li><a href="../../../index.html">Sprout v1.0 documentation</a> &raquo;</li>
<li><a href="../../index.html" >Sprout C++ Libraries</a> &raquo;</li>
<li><a href="../../libraries.html" >Libraries</a> &raquo;</li>
<li><a href="index.html" accesskey="U">Sprout.Algorithm</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="max-element">
<h1>max_element<a class="headerlink" href="#max-element" title="Permalink to this headline"></a></h1>
<div class="section" id="interface">
<h2>Interface<a class="headerlink" href="#interface" title="Permalink to this headline"></a></h2>
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span><span class="o">&lt;</span><span class="k">typename</span> <span class="n">ForwardIterator</span><span class="o">&gt;</span>
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="n">ForwardIterator</span>
<span class="n">max_element</span><span class="p">(</span><span class="n">ForwardIterator</span> <span class="n">first</span><span class="p">,</span> <span class="n">ForwardIterator</span> <span class="n">last</span><span class="p">);</span>
<span class="k">template</span><span class="o">&lt;</span><span class="k">typename</span> <span class="n">ForwardIterator</span><span class="p">,</span> <span class="k">typename</span> <span class="n">Compare</span><span class="o">&gt;</span>
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="n">ForwardIterator</span>
<span class="n">max_element</span><span class="p">(</span><span class="n">ForwardIterator</span> <span class="n">first</span><span class="p">,</span> <span class="n">ForwardIterator</span> <span class="n">last</span><span class="p">,</span> <span class="n">Compare</span> <span class="n">comp</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="returns">
<h2>Returns<a class="headerlink" href="#returns" title="Permalink to this headline"></a></h2>
<div class="line-block">
<div class="line">The first iterator i in the range [first,last) such that for any iterator j in the range [first,last) the following corresponding conditions hold: <tt class="docutils literal"><span class="pre">!(*i</span> <span class="pre">&lt;</span> <span class="pre">*j)</span></tt> or <tt class="docutils literal"><span class="pre">!comp(*i,</span> <span class="pre">*j)</span></tt>.</div>
<div class="line">Returns last if <tt class="docutils literal"><span class="pre">first</span> <span class="pre">==</span> <span class="pre">last</span></tt>.</div>
</div>
</div>
<div class="section" id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline"></a></h2>
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include &lt;sprout/algorithm/max_element.hpp&gt;</span>
<span class="cp">#include &lt;sprout/array.hpp&gt;</span>
<span class="cp">#include &lt;sprout/container.hpp&gt;</span>
<span class="k">using</span> <span class="k">namespace</span> <span class="n">sprout</span><span class="p">;</span>
<span class="n">SPROUT_STATIC_CONSTEXPR</span> <span class="k">auto</span> <span class="n">input</span> <span class="o">=</span> <span class="n">array</span><span class="o">&lt;</span><span class="kt">int</span><span class="p">,</span> <span class="mi">10</span><span class="o">&gt;</span><span class="p">{{</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">}};</span>
<span class="n">SPROUT_STATIC_CONSTEXPR</span> <span class="k">auto</span> <span class="n">result</span> <span class="o">=</span> <span class="n">sprout</span><span class="o">::</span><span class="n">max_element</span><span class="p">(</span><span class="n">begin</span><span class="p">(</span><span class="n">input</span><span class="p">),</span> <span class="n">end</span><span class="p">(</span><span class="n">input</span><span class="p">));</span>
<span class="n">static_assert</span><span class="p">(</span><span class="o">*</span><span class="n">result</span> <span class="o">==</span> <span class="mi">10</span><span class="p">,</span> <span class="s">&quot;a min element is 10.&quot;</span><span class="p">);</span>
<span class="n">static_assert</span><span class="p">(</span><span class="n">result</span> <span class="o">-</span> <span class="n">begin</span><span class="p">(</span><span class="n">input</span><span class="p">)</span> <span class="o">==</span> <span class="mi">9</span><span class="p">,</span> <span class="s">&quot;a min element position is 9.&quot;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="complexity">
<h2>Complexity<a class="headerlink" href="#complexity" title="Permalink to this headline"></a></h2>
<div class="line-block">
<div class="line">Exactly <tt class="docutils literal"><span class="pre">max((last</span> <span class="pre">-</span> <span class="pre">first)</span> <span class="pre">-</span> <span class="pre">1,</span> <span class="pre">0)</span></tt> applications of the corresponding comparisons.</div>
<div class="line">Recursive function invocations in <em>O(logN)</em> (logarithmic) depth.</div>
</div>
</div>
<div class="section" id="header">
<h2>Header<a class="headerlink" href="#header" title="Permalink to this headline"></a></h2>
<div class="line-block">
<div class="line"><tt class="docutils literal"><span class="pre">sprout/algorithm/max_element.hpp</span></tt></div>
<div class="line">Convenience header: <tt class="docutils literal"><span class="pre">sprout/algorithm.hpp</span></tt></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="../../../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference external" href="#">max_element</a><ul>
<li><a class="reference external" href="#interface">Interface</a></li>
<li><a class="reference external" href="#returns">Returns</a></li>
<li><a class="reference external" href="#examples">Examples</a></li>
<li><a class="reference external" href="#complexity">Complexity</a></li>
<li><a class="reference external" href="#header">Header</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="min_element.html"
title="previous chapter">min_element</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="minmax_element.html"
title="next chapter">minmax_element</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../../_sources/libs/sprout/algorithm/max_element.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../../../search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="minmax_element.html" title="minmax_element"
>next</a> |</li>
<li class="right" >
<a href="min_element.html" title="min_element"
>previous</a> |</li>
<li><a href="../../../index.html">Sprout v1.0 documentation</a> &raquo;</li>
<li><a href="../../index.html" >Sprout C++ Libraries</a> &raquo;</li>
<li><a href="../../libraries.html" >Libraries</a> &raquo;</li>
<li><a href="index.html" >Sprout.Algorithm</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Bolero MURAKAMI.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.4.
</div>
</body>
</html>

View file

@ -122,7 +122,7 @@
<h2>Remarks<a class="headerlink" href="#id4" title="Permalink to this headline"></a></h2>
<div class="line-block">
<div class="line">Returns a copy of the leftmost argument when several arguments are equivalent to the smallest.</div>
<div class="line">If an implementation not support C++14 initializer_list (SPROUT_NO_CXX14_INITIALIZER_LIST defined), then this function is not specified constexpr.</div>
<div class="line">If an implementation not support C++14 initializer_list (<tt class="docutils literal"><span class="pre">SPROUT_NO_CXX14_INITIALIZER_LIST</span></tt> defined), then this function is not specified constexpr.</div>
</div>
</div>
<div class="section" id="complexity">

View file

@ -0,0 +1,172 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>min_element &mdash; Sprout v1.0 documentation</title>
<link rel="stylesheet" href="../../../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../../',
VERSION: '1.0',
COLLAPSE_MODINDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../../../_static/jquery.js"></script>
<script type="text/javascript" src="../../../_static/doctools.js"></script>
<link rel="top" title="Sprout v1.0 documentation" href="../../../index.html" />
<link rel="up" title="Sprout.Algorithm" href="index.html" />
<link rel="next" title="max_element" href="max_element.html" />
<link rel="prev" title="minmax" href="minmax.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="max_element.html" title="max_element"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="minmax.html" title="minmax"
accesskey="P">previous</a> |</li>
<li><a href="../../../index.html">Sprout v1.0 documentation</a> &raquo;</li>
<li><a href="../../index.html" >Sprout C++ Libraries</a> &raquo;</li>
<li><a href="../../libraries.html" >Libraries</a> &raquo;</li>
<li><a href="index.html" accesskey="U">Sprout.Algorithm</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="min-element">
<h1>min_element<a class="headerlink" href="#min-element" title="Permalink to this headline"></a></h1>
<div class="section" id="interface">
<h2>Interface<a class="headerlink" href="#interface" title="Permalink to this headline"></a></h2>
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span><span class="o">&lt;</span><span class="k">typename</span> <span class="n">ForwardIterator</span><span class="o">&gt;</span>
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="n">ForwardIterator</span>
<span class="n">min_element</span><span class="p">(</span><span class="n">ForwardIterator</span> <span class="n">first</span><span class="p">,</span> <span class="n">ForwardIterator</span> <span class="n">last</span><span class="p">);</span>
<span class="k">template</span><span class="o">&lt;</span><span class="k">typename</span> <span class="n">ForwardIterator</span><span class="p">,</span> <span class="k">typename</span> <span class="n">Compare</span><span class="o">&gt;</span>
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="n">ForwardIterator</span>
<span class="n">min_element</span><span class="p">(</span><span class="n">ForwardIterator</span> <span class="n">first</span><span class="p">,</span> <span class="n">ForwardIterator</span> <span class="n">last</span><span class="p">,</span> <span class="n">Compare</span> <span class="n">comp</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="returns">
<h2>Returns<a class="headerlink" href="#returns" title="Permalink to this headline"></a></h2>
<div class="line-block">
<div class="line">The first iterator i in the range [first,last) such that for any iterator j in the range [first,last) the following corresponding conditions hold: <tt class="docutils literal"><span class="pre">!(*j</span> <span class="pre">&lt;</span> <span class="pre">*i)</span></tt> or <tt class="docutils literal"><span class="pre">!comp(*j,</span> <span class="pre">*i)</span></tt>.</div>
<div class="line">Returns last if <tt class="docutils literal"><span class="pre">first</span> <span class="pre">==</span> <span class="pre">last</span></tt>.</div>
</div>
</div>
<div class="section" id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline"></a></h2>
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include &lt;sprout/algorithm/min_element.hpp&gt;</span>
<span class="cp">#include &lt;sprout/array.hpp&gt;</span>
<span class="cp">#include &lt;sprout/container.hpp&gt;</span>
<span class="k">using</span> <span class="k">namespace</span> <span class="n">sprout</span><span class="p">;</span>
<span class="n">SPROUT_STATIC_CONSTEXPR</span> <span class="k">auto</span> <span class="n">input</span> <span class="o">=</span> <span class="n">array</span><span class="o">&lt;</span><span class="kt">int</span><span class="p">,</span> <span class="mi">10</span><span class="o">&gt;</span><span class="p">{{</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">}};</span>
<span class="n">SPROUT_STATIC_CONSTEXPR</span> <span class="k">auto</span> <span class="n">result</span> <span class="o">=</span> <span class="n">sprout</span><span class="o">::</span><span class="n">min_element</span><span class="p">(</span><span class="n">begin</span><span class="p">(</span><span class="n">input</span><span class="p">),</span> <span class="n">end</span><span class="p">(</span><span class="n">input</span><span class="p">));</span>
<span class="n">static_assert</span><span class="p">(</span><span class="o">*</span><span class="n">result</span> <span class="o">==</span> <span class="mi">1</span><span class="p">,</span> <span class="s">&quot;a min element is 1.&quot;</span><span class="p">);</span>
<span class="n">static_assert</span><span class="p">(</span><span class="n">result</span> <span class="o">-</span> <span class="n">begin</span><span class="p">(</span><span class="n">input</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">,</span> <span class="s">&quot;a min element position is 0.&quot;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="complexity">
<h2>Complexity<a class="headerlink" href="#complexity" title="Permalink to this headline"></a></h2>
<div class="line-block">
<div class="line">Exactly <tt class="docutils literal"><span class="pre">max((last</span> <span class="pre">-</span> <span class="pre">first)</span> <span class="pre">-</span> <span class="pre">1,</span> <span class="pre">0)</span></tt> applications of the corresponding comparisons.</div>
<div class="line">Recursive function invocations in <em>O(logN)</em> (logarithmic) depth.</div>
</div>
</div>
<div class="section" id="header">
<h2>Header<a class="headerlink" href="#header" title="Permalink to this headline"></a></h2>
<div class="line-block">
<div class="line"><tt class="docutils literal"><span class="pre">sprout/algorithm/min_element.hpp</span></tt></div>
<div class="line">Convenience header: <tt class="docutils literal"><span class="pre">sprout/algorithm.hpp</span></tt></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="../../../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference external" href="#">min_element</a><ul>
<li><a class="reference external" href="#interface">Interface</a></li>
<li><a class="reference external" href="#returns">Returns</a></li>
<li><a class="reference external" href="#examples">Examples</a></li>
<li><a class="reference external" href="#complexity">Complexity</a></li>
<li><a class="reference external" href="#header">Header</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="minmax.html"
title="previous chapter">minmax</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="max_element.html"
title="next chapter">max_element</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../../_sources/libs/sprout/algorithm/min_element.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../../../search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="max_element.html" title="max_element"
>next</a> |</li>
<li class="right" >
<a href="minmax.html" title="minmax"
>previous</a> |</li>
<li><a href="../../../index.html">Sprout v1.0 documentation</a> &raquo;</li>
<li><a href="../../index.html" >Sprout C++ Libraries</a> &raquo;</li>
<li><a href="../../libraries.html" >Libraries</a> &raquo;</li>
<li><a href="index.html" >Sprout.Algorithm</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Bolero MURAKAMI.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.4.
</div>
</body>
</html>

View file

@ -21,6 +21,7 @@
<script type="text/javascript" src="../../../_static/doctools.js"></script>
<link rel="top" title="Sprout v1.0 documentation" href="../../../index.html" />
<link rel="up" title="Sprout.Algorithm" href="index.html" />
<link rel="next" title="min_element" href="min_element.html" />
<link rel="prev" title="max" href="max.html" />
</head>
<body>
@ -30,6 +31,9 @@
<li class="right" style="margin-right: 10px">
<a href="../../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="min_element.html" title="min_element"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="max.html" title="max"
accesskey="P">previous</a> |</li>
@ -129,7 +133,7 @@
<div class="line-block">
<div class="line">x is a copy of the leftmost argument when several arguments are equivalent to the smallest.</div>
<div class="line">y is a copy of the rightmost argument when several arguments are equivalent to the largest.</div>
<div class="line">If an implementation not support C++14 initializer_list (SPROUT_NO_CXX14_INITIALIZER_LIST defined), then this function is not specified constexpr.</div>
<div class="line">If an implementation not support C++14 initializer_list (<tt class="docutils literal"><span class="pre">SPROUT_NO_CXX14_INITIALIZER_LIST</span></tt> defined), then this function is not specified constexpr.</div>
</div>
</div>
<div class="section" id="id6">
@ -177,6 +181,9 @@
<h4>Previous topic</h4>
<p class="topless"><a href="max.html"
title="previous chapter">max</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="min_element.html"
title="next chapter">min_element</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../../_sources/libs/sprout/algorithm/minmax.txt"
@ -205,6 +212,9 @@
<li class="right" style="margin-right: 10px">
<a href="../../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="min_element.html" title="min_element"
>next</a> |</li>
<li class="right" >
<a href="max.html" title="max"
>previous</a> |</li>

View file

@ -0,0 +1,163 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>minmax_element &mdash; Sprout v1.0 documentation</title>
<link rel="stylesheet" href="../../../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../../',
VERSION: '1.0',
COLLAPSE_MODINDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../../../_static/jquery.js"></script>
<script type="text/javascript" src="../../../_static/doctools.js"></script>
<link rel="top" title="Sprout v1.0 documentation" href="../../../index.html" />
<link rel="up" title="Sprout.Algorithm" href="index.html" />
<link rel="prev" title="max_element" href="max_element.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="max_element.html" title="max_element"
accesskey="P">previous</a> |</li>
<li><a href="../../../index.html">Sprout v1.0 documentation</a> &raquo;</li>
<li><a href="../../index.html" >Sprout C++ Libraries</a> &raquo;</li>
<li><a href="../../libraries.html" >Libraries</a> &raquo;</li>
<li><a href="index.html" accesskey="U">Sprout.Algorithm</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="minmax-element">
<h1>minmax_element<a class="headerlink" href="#minmax-element" title="Permalink to this headline"></a></h1>
<div class="section" id="interface">
<h2>Interface<a class="headerlink" href="#interface" title="Permalink to this headline"></a></h2>
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span><span class="o">&lt;</span><span class="k">typename</span> <span class="n">ForwardIterator</span><span class="o">&gt;</span>
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="n">sprout</span><span class="o">::</span><span class="n">pair</span><span class="o">&lt;</span><span class="n">ForwardIterator</span><span class="p">,</span> <span class="n">ForwardIterator</span><span class="o">&gt;</span>
<span class="n">minmax_element</span><span class="p">(</span><span class="n">ForwardIterator</span> <span class="n">first</span><span class="p">,</span> <span class="n">ForwardIterator</span> <span class="n">last</span><span class="p">);</span>
<span class="k">template</span><span class="o">&lt;</span><span class="k">typename</span> <span class="n">ForwardIterator</span><span class="p">,</span> <span class="k">typename</span> <span class="n">Compare</span><span class="o">&gt;</span>
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="n">sprout</span><span class="o">::</span><span class="n">pair</span><span class="o">&lt;</span><span class="n">ForwardIterator</span><span class="p">,</span> <span class="n">ForwardIterator</span><span class="o">&gt;</span>
<span class="n">minmax_element</span><span class="p">(</span><span class="n">ForwardIterator</span> <span class="n">first</span><span class="p">,</span> <span class="n">ForwardIterator</span> <span class="n">last</span><span class="p">,</span> <span class="n">Compare</span> <span class="n">comp</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="returns">
<h2>Returns<a class="headerlink" href="#returns" title="Permalink to this headline"></a></h2>
<div class="line-block">
<div class="line"><tt class="docutils literal"><span class="pre">make_pair(first,</span> <span class="pre">first)</span></tt> if [first,last) is empty, otherwise <tt class="docutils literal"><span class="pre">make_pair(m,</span> <span class="pre">M)</span></tt>, where m is the first iterator in [first,last) such that no iterator in the range refers to a smaller element, and where M is the last iterator in [first,last) such that no iterator in the range refers to a larger element.</div>
</div>
</div>
<div class="section" id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline"></a></h2>
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include &lt;sprout/algorithm/minmax_element.hpp&gt;</span>
<span class="cp">#include &lt;sprout/array.hpp&gt;</span>
<span class="cp">#include &lt;sprout/container.hpp&gt;</span>
<span class="k">using</span> <span class="k">namespace</span> <span class="n">sprout</span><span class="p">;</span>
<span class="n">SPROUT_STATIC_CONSTEXPR</span> <span class="k">auto</span> <span class="n">input</span> <span class="o">=</span> <span class="n">array</span><span class="o">&lt;</span><span class="kt">int</span><span class="p">,</span> <span class="mi">10</span><span class="o">&gt;</span><span class="p">{{</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">}};</span>
<span class="n">SPROUT_STATIC_CONSTEXPR</span> <span class="k">auto</span> <span class="n">result</span> <span class="o">=</span> <span class="n">sprout</span><span class="o">::</span><span class="n">minmax_element</span><span class="p">(</span><span class="n">begin</span><span class="p">(</span><span class="n">input</span><span class="p">),</span> <span class="n">end</span><span class="p">(</span><span class="n">input</span><span class="p">));</span>
<span class="n">static_assert</span><span class="p">(</span><span class="o">*</span><span class="n">result</span><span class="p">.</span><span class="n">first</span> <span class="o">==</span> <span class="mi">1</span><span class="p">,</span> <span class="s">&quot;a min element is 1.&quot;</span><span class="p">);</span>
<span class="n">static_assert</span><span class="p">(</span><span class="o">*</span><span class="n">result</span><span class="p">.</span><span class="n">second</span> <span class="o">==</span> <span class="mi">10</span><span class="p">,</span> <span class="s">&quot;a max element is 10.&quot;</span><span class="p">);</span>
<span class="n">static_assert</span><span class="p">(</span><span class="n">result</span><span class="p">.</span><span class="n">first</span> <span class="o">-</span> <span class="n">begin</span><span class="p">(</span><span class="n">input</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">,</span> <span class="s">&quot;a min element position is 0.&quot;</span><span class="p">);</span>
<span class="n">static_assert</span><span class="p">(</span><span class="n">result</span><span class="p">.</span><span class="n">second</span> <span class="o">-</span> <span class="n">begin</span><span class="p">(</span><span class="n">input</span><span class="p">)</span> <span class="o">==</span> <span class="mi">9</span><span class="p">,</span> <span class="s">&quot;a max element position is 9.&quot;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="complexity">
<h2>Complexity<a class="headerlink" href="#complexity" title="Permalink to this headline"></a></h2>
<div class="line-block">
<div class="line">At most <tt class="docutils literal"><span class="pre">max(floor((3/2)*(N</span> <span class="pre">-</span> <span class="pre">1)),</span> <span class="pre">0)</span></tt> applications of the corresponding predicate, where N is <tt class="docutils literal"><span class="pre">distance(first,</span> <span class="pre">last)</span></tt>.</div>
<div class="line">Recursive function invocations in <em>O(logN)</em> (logarithmic) depth.</div>
</div>
</div>
<div class="section" id="header">
<h2>Header<a class="headerlink" href="#header" title="Permalink to this headline"></a></h2>
<div class="line-block">
<div class="line"><tt class="docutils literal"><span class="pre">sprout/algorithm/minmax_element.hpp</span></tt></div>
<div class="line">Convenience header: <tt class="docutils literal"><span class="pre">sprout/algorithm.hpp</span></tt></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="../../../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference external" href="#">minmax_element</a><ul>
<li><a class="reference external" href="#interface">Interface</a></li>
<li><a class="reference external" href="#returns">Returns</a></li>
<li><a class="reference external" href="#examples">Examples</a></li>
<li><a class="reference external" href="#complexity">Complexity</a></li>
<li><a class="reference external" href="#header">Header</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="max_element.html"
title="previous chapter">max_element</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../../_sources/libs/sprout/algorithm/minmax_element.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../../../search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="max_element.html" title="max_element"
>previous</a> |</li>
<li><a href="../../../index.html">Sprout v1.0 documentation</a> &raquo;</li>
<li><a href="../../index.html" >Sprout C++ Libraries</a> &raquo;</li>
<li><a href="../../libraries.html" >Libraries</a> &raquo;</li>
<li><a href="index.html" >Sprout.Algorithm</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Bolero MURAKAMI.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.4.
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

View file

@ -42,6 +42,9 @@ Sprout.Algorithm
min
max
minmax
min_element
max_element
minmax_element
.. _sprout-algorithm-non_modifying:
*******************************************************************************

View file

@ -70,7 +70,7 @@ Remarks
========================================
| Returns a copy of the leftmost argument when several arguments are equivalent to the largest.
| If an implementation not support C++14 initializer_list (SPROUT_NO_CXX14_INITIALIZER_LIST defined), then this function is not specified constexpr.
| If an implementation not support C++14 initializer_list (``SPROUT_NO_CXX14_INITIALIZER_LIST`` defined), then this function is not specified constexpr.
Complexity
========================================

View file

@ -0,0 +1,49 @@
.. _sprout-algorithm-max_element:
###############################################################################
max_element
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator>
inline SPROUT_CONSTEXPR ForwardIterator
max_element(ForwardIterator first, ForwardIterator last);
template<typename ForwardIterator, typename Compare>
inline SPROUT_CONSTEXPR ForwardIterator
max_element(ForwardIterator first, ForwardIterator last, Compare comp);
Returns
========================================
| The first iterator i in the range [first,last) such that for any iterator j in the range [first,last) the following corresponding conditions hold: ``!(*i < *j)`` or ``!comp(*i, *j)``.
| Returns last if ``first == last``.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/max_element.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::max_element(begin(input), end(input));
static_assert(*result == 10, "a min element is 10.");
static_assert(result - begin(input) == 9, "a min element position is 9.");
Complexity
========================================
| Exactly ``max((last - first) - 1, 0)`` applications of the corresponding comparisons.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/max_element.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -70,7 +70,7 @@ Remarks
========================================
| Returns a copy of the leftmost argument when several arguments are equivalent to the smallest.
| If an implementation not support C++14 initializer_list (SPROUT_NO_CXX14_INITIALIZER_LIST defined), then this function is not specified constexpr.
| If an implementation not support C++14 initializer_list (``SPROUT_NO_CXX14_INITIALIZER_LIST`` defined), then this function is not specified constexpr.
Complexity
========================================

View file

@ -0,0 +1,49 @@
.. _sprout-algorithm-min_element:
###############################################################################
min_element
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator>
inline SPROUT_CONSTEXPR ForwardIterator
min_element(ForwardIterator first, ForwardIterator last);
template<typename ForwardIterator, typename Compare>
inline SPROUT_CONSTEXPR ForwardIterator
min_element(ForwardIterator first, ForwardIterator last, Compare comp);
Returns
========================================
| The first iterator i in the range [first,last) such that for any iterator j in the range [first,last) the following corresponding conditions hold: ``!(*j < *i)`` or ``!comp(*j, *i)``.
| Returns last if ``first == last``.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/min_element.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::min_element(begin(input), end(input));
static_assert(*result == 1, "a min element is 1.");
static_assert(result - begin(input) == 0, "a min element position is 0.");
Complexity
========================================
| Exactly ``max((last - first) - 1, 0)`` applications of the corresponding comparisons.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/min_element.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -80,7 +80,7 @@ Remarks
| x is a copy of the leftmost argument when several arguments are equivalent to the smallest.
| y is a copy of the rightmost argument when several arguments are equivalent to the largest.
| If an implementation not support C++14 initializer_list (SPROUT_NO_CXX14_INITIALIZER_LIST defined), then this function is not specified constexpr.
| If an implementation not support C++14 initializer_list (``SPROUT_NO_CXX14_INITIALIZER_LIST`` defined), then this function is not specified constexpr.
Complexity
========================================

View file

@ -0,0 +1,50 @@
.. _sprout-algorithm-minmax_element:
###############################################################################
minmax_element
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator>
inline SPROUT_CONSTEXPR sprout::pair<ForwardIterator, ForwardIterator>
minmax_element(ForwardIterator first, ForwardIterator last);
template<typename ForwardIterator, typename Compare>
inline SPROUT_CONSTEXPR sprout::pair<ForwardIterator, ForwardIterator>
minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
Returns
========================================
| ``make_pair(first, first)`` if [first,last) is empty, otherwise ``make_pair(m, M)``, where m is the first iterator in [first,last) such that no iterator in the range refers to a smaller element, and where M is the last iterator in [first,last) such that no iterator in the range refers to a larger element.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/minmax_element.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::minmax_element(begin(input), end(input));
static_assert(*result.first == 1, "a min element is 1.");
static_assert(*result.second == 10, "a max element is 10.");
static_assert(result.first - begin(input) == 0, "a min element position is 0.");
static_assert(result.second - begin(input) == 9, "a max element position is 9.");
Complexity
========================================
| At most ``max(floor((3/2)*(N - 1)), 0)`` applications of the corresponding predicate, where N is ``distance(first, last)``.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/minmax_element.hpp``
| Convenience header: ``sprout/algorithm.hpp``