add doc: lexicographical_compare, clamp

This commit is contained in:
Bolero-MURAKAMI 2013-08-24 18:02:54 +09:00
parent 29babfce4e
commit 227a35c29c
38 changed files with 997 additions and 28 deletions

View file

@ -14,7 +14,7 @@ Interface
Returns
========================================
| *true* if [first,last) is empty or if ``pred(*i)`` is true for every iterator i in the range [first,last), and *false* otherwise.
| true if [first,last) is empty or if ``pred(*i)`` is true for every iterator i in the range [first,last), and false otherwise.
Examples
========================================

View file

@ -14,7 +14,7 @@ Interface
Returns
========================================
| *true* if [first,last) is empty or if ``*i == value`` is true for every iterator i in the range [first,last), and *false* otherwise.
| true if [first,last) is empty or if ``*i == value`` is true for every iterator i in the range [first,last), and false otherwise.
Examples
========================================

View file

@ -14,7 +14,7 @@ Interface
Returns
========================================
| *false* if [first,last) is empty or if there is no iterator i in the range [first,last) such that ``pred(*i)`` is true, and *true* otherwise.
| false if [first,last) is empty or if there is no iterator i in the range [first,last) such that ``pred(*i)`` is true, and true otherwise.
Examples
========================================

View file

@ -14,7 +14,7 @@ Interface
Returns
========================================
| *false* if [first,last) is empty or if there is no iterator i in the range [first,last) such that ``*i == value`` is true, and *true* otherwise.
| false if [first,last) is empty or if there is no iterator i in the range [first,last) such that ``*i == value`` is true, and true otherwise.
Examples
========================================

View file

@ -0,0 +1,57 @@
.. _sprout-algorithm-clamp:
###############################################################################
clamp
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename T>
inline SPROUT_CONSTEXPR T const&
clamp(T const& value, typename sprout::identity<T>::type const& low, typename sprout::identity<T>::type const& high);
template<typename T, typename Compare>
inline SPROUT_CONSTEXPR T const&
clamp(T const& value, typename sprout::identity<T>::type const& low, typename sprout::identity<T>::type const& high, Compare comp);
Requires
========================================
| Type T is LessThanComparable.
Returns
========================================
| low if the following corresponding conditions hold: ``value < low``, ``comp(value, low)``.
| high if the following corresponding conditions hold: ``high < value``, ``comp(high, value)``.
| Otherwise, returns value.
Remarks
========================================
| Using clamp with floating point numbers may give unexpected results if one of the values is NaN.
Complexity
========================================
| Exactly one or two comparisons.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/clamp.hpp>
#include <sprout/array.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{0, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::clamp(20, input[0], input[1]);
static_assert(result == 10, "clamped value is 10.");
Header
========================================
| ``sprout/algorithm/clamp.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -45,6 +45,9 @@ Sprout.Algorithm
min_element
max_element
minmax_element
lexicographical_compare
tristate_lexicographical_compare
clamp
.. _sprout-algorithm-non_modifying:
*******************************************************************************

View file

@ -0,0 +1,72 @@
.. _sprout-algorithm-lexicographical_compare:
###############################################################################
lexicographical_compare
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename InputIterator1, typename InputIterator2>
inline SPROUT_CONSTEXPR bool
lexicographical_compare(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2
);
template<typename InputIterator1, typename InputIterator2, typename Compare>
inline SPROUT_CONSTEXPR bool
lexicographical_compare(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
Compare comp
);
Returns
========================================
| true if the sequence of elements defined by the range [first1,last1) is lexicographically less than the sequence of elements defined by the range [first2,last2) and false otherwise.
Remarks
========================================
| If two sequences have the same number of elements and their corresponding elements are equivalent, then neither sequence is lexicographically less than the other.
| If one sequence is a prefix of the other, then the shorter sequence is lexicographically less than the longer sequence.
| Otherwise, the lexicographical comparison of the sequences yields the same result as the comparison of the first corresponding pair of elements that are not equivalent.
.. sourcecode:: c++
for (; first1 != last1 && first2 != last2; ++first1, ++first2) {
if (*first1 < *first2) return true;
if (*first2 < *first1) return false;
}
return first1 == last1 && first2 != last2;
| An empty sequence is lexicographically less than any non-empty sequence, but not less than any empty sequence.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/lexicographical_compare.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input1 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto input2 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 11, 12, 13}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::lexicographical_compare(begin(input1), end(input1), begin(input2), end(input2));
static_assert(result, "input1 < input2 by lexicographical comparison.");
Complexity
========================================
| At most ``2*min((last1 - first1), (last2 - first2))`` applications of the corresponding comparison.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/lexicographical_compare.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -14,7 +14,7 @@ Interface
Returns
========================================
| *true* if [first,last) is empty or if ``pred(*i)`` is false for every iterator i in the range [first,last), and *false* otherwise.
| true if [first,last) is empty or if ``pred(*i)`` is false for every iterator i in the range [first,last), and false otherwise.
Examples
========================================

View file

@ -14,7 +14,7 @@ Interface
Returns
========================================
| *true* if [first,last) is empty or if ``*i == value`` is false for every iterator i in the range [first,last), and *false* otherwise.
| true if [first,last) is empty or if ``*i == value`` is false for every iterator i in the range [first,last), and false otherwise.
Examples
========================================

View file

@ -14,7 +14,7 @@ Interface
Returns
========================================
| *true* if [first,last) is not empty and there is only one iterator i in the range [first,last) such that ``pred(*i)`` is true, and *false* otherwise.
| true if [first,last) is not empty and there is only one iterator i in the range [first,last) such that ``pred(*i)`` is true, and false otherwise.
Examples
========================================

View file

@ -14,7 +14,7 @@ Interface
Returns
========================================
| *true* if [first,last) is not empty and there is only one iterator i in the range [first,last) such that ``*i == value`` is true, and *false* otherwise.
| true if [first,last) is not empty and there is only one iterator i in the range [first,last) such that ``*i == value`` is true, and false otherwise.
Examples
========================================

View file

@ -0,0 +1,66 @@
.. _sprout-algorithm-tristate_lexicographical_compare:
###############################################################################
tristate_lexicographical_compare
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename InputIterator1, typename InputIterator2>
inline SPROUT_CONSTEXPR int
tristate_lexicographical_compare(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2
);
template<typename InputIterator1, typename InputIterator2, typename Compare>
inline SPROUT_CONSTEXPR int
tristate_lexicographical_compare(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
Compare comp
);
Returns
========================================
| A value less than zero if the sequence of elements defined by the range [first1,last1) is lexicographically less than the sequence of elements defined by the range [first2,last2) and false otherwise.
| A value greater than zero if the sequence of elements defined by the range [first1,last1) is lexicographically greater than the sequence of elements defined by the range [first2,last2) and false otherwise.
| Otherwise, returns a zero value.
Remarks
========================================
| If two sequences have the same number of elements and their corresponding elements are equivalent, then neither sequence is lexicographically less than the other.
| If one sequence is a prefix of the other, then the shorter sequence is lexicographically less than the longer sequence.
| Otherwise, the lexicographical comparison of the sequences yields the same result as the comparison of the first corresponding pair of elements that are not equivalent.
| An empty sequence is lexicographically less than any non-empty sequence, but not less than any empty sequence.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/tristate_lexicographical_compare.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input1 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto input2 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 11, 12, 13}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::tristate_lexicographical_compare(begin(input1), end(input1), begin(input2), end(input2));
static_assert(result < 0, "input1 < input2 by lexicographical comparison.");
Complexity
========================================
| At most ``2*min((last1 - first1), (last2 - first2)) + O(1)`` applications of the corresponding comparison.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/tristate_lexicographical_compare.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -62,7 +62,7 @@
<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"><em>true</em> if [first,last) is empty or if <tt class="docutils literal"><span class="pre">pred(*i)</span></tt> is true for every iterator i in the range [first,last), and <em>false</em> otherwise.</div>
<div class="line">true if [first,last) is empty or if <tt class="docutils literal"><span class="pre">pred(*i)</span></tt> is true for every iterator i in the range [first,last), and false otherwise.</div>
</div>
</div>
<div class="section" id="examples">

View file

@ -62,7 +62,7 @@
<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"><em>true</em> if [first,last) is empty or if <tt class="docutils literal"><span class="pre">*i</span> <span class="pre">==</span> <span class="pre">value</span></tt> is true for every iterator i in the range [first,last), and <em>false</em> otherwise.</div>
<div class="line">true if [first,last) is empty or if <tt class="docutils literal"><span class="pre">*i</span> <span class="pre">==</span> <span class="pre">value</span></tt> is true for every iterator i in the range [first,last), and false otherwise.</div>
</div>
</div>
<div class="section" id="examples">

View file

@ -62,7 +62,7 @@
<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"><em>false</em> if [first,last) is empty or if there is no iterator i in the range [first,last) such that <tt class="docutils literal"><span class="pre">pred(*i)</span></tt> is true, and <em>true</em> otherwise.</div>
<div class="line">false if [first,last) is empty or if there is no iterator i in the range [first,last) such that <tt class="docutils literal"><span class="pre">pred(*i)</span></tt> is true, and true otherwise.</div>
</div>
</div>
<div class="section" id="examples">

View file

@ -62,7 +62,7 @@
<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"><em>false</em> if [first,last) is empty or if there is no iterator i in the range [first,last) such that <tt class="docutils literal"><span class="pre">*i</span> <span class="pre">==</span> <span class="pre">value</span></tt> is true, and <em>true</em> otherwise.</div>
<div class="line">false if [first,last) is empty or if there is no iterator i in the range [first,last) such that <tt class="docutils literal"><span class="pre">*i</span> <span class="pre">==</span> <span class="pre">value</span></tt> is true, and true otherwise.</div>
</div>
</div>
<div class="section" id="examples">

View file

@ -0,0 +1,174 @@
<!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>clamp &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="tristate_lexicographical_compare" href="tristate_lexicographical_compare.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="tristate_lexicographical_compare.html" title="tristate_lexicographical_compare"
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="clamp">
<h1>clamp<a class="headerlink" href="#clamp" 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">T</span><span class="o">&gt;</span>
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="n">T</span> <span class="k">const</span><span class="o">&amp;</span>
<span class="n">clamp</span><span class="p">(</span><span class="n">T</span> <span class="k">const</span><span class="o">&amp;</span> <span class="n">value</span><span class="p">,</span> <span class="k">typename</span> <span class="n">sprout</span><span class="o">::</span><span class="n">identity</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;::</span><span class="n">type</span> <span class="k">const</span><span class="o">&amp;</span> <span class="n">low</span><span class="p">,</span> <span class="k">typename</span> <span class="n">sprout</span><span class="o">::</span><span class="n">identity</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;::</span><span class="n">type</span> <span class="k">const</span><span class="o">&amp;</span> <span class="n">high</span><span class="p">);</span>
<span class="k">template</span><span class="o">&lt;</span><span class="k">typename</span> <span class="n">T</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">T</span> <span class="k">const</span><span class="o">&amp;</span>
<span class="n">clamp</span><span class="p">(</span><span class="n">T</span> <span class="k">const</span><span class="o">&amp;</span> <span class="n">value</span><span class="p">,</span> <span class="k">typename</span> <span class="n">sprout</span><span class="o">::</span><span class="n">identity</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;::</span><span class="n">type</span> <span class="k">const</span><span class="o">&amp;</span> <span class="n">low</span><span class="p">,</span> <span class="k">typename</span> <span class="n">sprout</span><span class="o">::</span><span class="n">identity</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;::</span><span class="n">type</span> <span class="k">const</span><span class="o">&amp;</span> <span class="n">high</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="requires">
<h2>Requires<a class="headerlink" href="#requires" title="Permalink to this headline"></a></h2>
<div class="line-block">
<div class="line">Type T is LessThanComparable.</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">low if the following corresponding conditions hold: <tt class="docutils literal"><span class="pre">value</span> <span class="pre">&lt;</span> <span class="pre">low</span></tt>, <tt class="docutils literal"><span class="pre">comp(value,</span> <span class="pre">low)</span></tt>.</div>
<div class="line">high if the following corresponding conditions hold: <tt class="docutils literal"><span class="pre">high</span> <span class="pre">&lt;</span> <span class="pre">value</span></tt>, <tt class="docutils literal"><span class="pre">comp(high,</span> <span class="pre">value)</span></tt>.</div>
<div class="line">Otherwise, returns value.</div>
</div>
</div>
<div class="section" id="remarks">
<h2>Remarks<a class="headerlink" href="#remarks" title="Permalink to this headline"></a></h2>
<div class="line-block">
<div class="line">Using clamp with floating point numbers may give unexpected results if one of the values is NaN.</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 one or two comparisons.</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/clamp.hpp&gt;</span>
<span class="cp">#include &lt;sprout/array.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">0</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">clamp</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="n">input</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">input</span><span class="p">[</span><span class="mi">1</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="mi">10</span><span class="p">,</span> <span class="s">&quot;clamped value is 10.&quot;</span><span class="p">);</span>
</pre></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/clamp.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="#">clamp</a><ul>
<li><a class="reference external" href="#interface">Interface</a></li>
<li><a class="reference external" href="#requires">Requires</a></li>
<li><a class="reference external" href="#returns">Returns</a></li>
<li><a class="reference external" href="#remarks">Remarks</a></li>
<li><a class="reference external" href="#complexity">Complexity</a></li>
<li><a class="reference external" href="#examples">Examples</a></li>
<li><a class="reference external" href="#header">Header</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="tristate_lexicographical_compare.html"
title="previous chapter">tristate_lexicographical_compare</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../../_sources/libs/sprout/algorithm/clamp.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="tristate_lexicographical_compare.html" title="tristate_lexicographical_compare"
>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

@ -116,14 +116,14 @@
<div class="section" id="lexicographical-comparison">
<h3>Lexicographical comparison<a class="headerlink" href="#lexicographical-comparison" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><tt class="xref docutils literal"><span class="pre">lexicographical_compare</span></tt></li>
<li><tt class="xref docutils literal"><span class="pre">tristate_lexicographical_compare</span></tt></li>
<li><a class="reference external" href="lexicographical_compare.html"><em>lexicographical_compare</em></a></li>
<li><a class="reference external" href="tristate_lexicographical_compare.html"><em>tristate_lexicographical_compare</em></a></li>
</ul>
</div>
<div class="section" id="clamp-algorithm">
<h3>Clamp algorithm<a class="headerlink" href="#clamp-algorithm" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><tt class="xref docutils literal"><span class="pre">clamp</span></tt></li>
<li><a class="reference external" href="clamp.html"><em>clamp</em></a></li>
</ul>
</div>
<div class="section" id="header">

View file

@ -0,0 +1,197 @@
<!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>lexicographical_compare &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="tristate_lexicographical_compare" href="tristate_lexicographical_compare.html" />
<link rel="prev" title="minmax_element" href="minmax_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="tristate_lexicographical_compare.html" title="tristate_lexicographical_compare"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="minmax_element.html" title="minmax_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="lexicographical-compare">
<h1>lexicographical_compare<a class="headerlink" href="#lexicographical-compare" 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">InputIterator1</span><span class="p">,</span> <span class="k">typename</span> <span class="n">InputIterator2</span><span class="o">&gt;</span>
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="kt">bool</span>
<span class="n">lexicographical_compare</span><span class="p">(</span>
<span class="n">InputIterator1</span> <span class="n">first1</span><span class="p">,</span> <span class="n">InputIterator1</span> <span class="n">last1</span><span class="p">,</span>
<span class="n">InputIterator2</span> <span class="n">first2</span><span class="p">,</span> <span class="n">InputIterator2</span> <span class="n">last2</span>
<span class="p">);</span>
<span class="k">template</span><span class="o">&lt;</span><span class="k">typename</span> <span class="n">InputIterator1</span><span class="p">,</span> <span class="k">typename</span> <span class="n">InputIterator2</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="kt">bool</span>
<span class="n">lexicographical_compare</span><span class="p">(</span>
<span class="n">InputIterator1</span> <span class="n">first1</span><span class="p">,</span> <span class="n">InputIterator1</span> <span class="n">last1</span><span class="p">,</span>
<span class="n">InputIterator2</span> <span class="n">first2</span><span class="p">,</span> <span class="n">InputIterator2</span> <span class="n">last2</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">true if the sequence of elements defined by the range [first1,last1) is lexicographically less than the sequence of elements defined by the range [first2,last2) and false otherwise.</div>
</div>
</div>
<div class="section" id="remarks">
<h2>Remarks<a class="headerlink" href="#remarks" title="Permalink to this headline"></a></h2>
<div class="line-block">
<div class="line">If two sequences have the same number of elements and their corresponding elements are equivalent, then neither sequence is lexicographically less than the other.</div>
<div class="line">If one sequence is a prefix of the other, then the shorter sequence is lexicographically less than the longer sequence.</div>
<div class="line">Otherwise, the lexicographical comparison of the sequences yields the same result as the comparison of the first corresponding pair of elements that are not equivalent.</div>
</div>
<div class="highlight-c++"><div class="highlight"><pre><span class="k">for</span> <span class="p">(;</span> <span class="n">first1</span> <span class="o">!=</span> <span class="n">last1</span> <span class="o">&amp;&amp;</span> <span class="n">first2</span> <span class="o">!=</span> <span class="n">last2</span><span class="p">;</span> <span class="o">++</span><span class="n">first1</span><span class="p">,</span> <span class="o">++</span><span class="n">first2</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">*</span><span class="n">first1</span> <span class="o">&lt;</span> <span class="o">*</span><span class="n">first2</span><span class="p">)</span> <span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="o">*</span><span class="n">first2</span> <span class="o">&lt;</span> <span class="o">*</span><span class="n">first1</span><span class="p">)</span> <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">return</span> <span class="n">first1</span> <span class="o">==</span> <span class="n">last1</span> <span class="o">&amp;&amp;</span> <span class="n">first2</span> <span class="o">!=</span> <span class="n">last2</span><span class="p">;</span>
</pre></div>
</div>
<div class="line-block">
<div class="line">An empty sequence is lexicographically less than any non-empty sequence, but not less than any empty sequence.</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/lexicographical_compare.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">input1</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">input2</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">11</span><span class="p">,</span> <span class="mi">12</span><span class="p">,</span> <span class="mi">13</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">lexicographical_compare</span><span class="p">(</span><span class="n">begin</span><span class="p">(</span><span class="n">input1</span><span class="p">),</span> <span class="n">end</span><span class="p">(</span><span class="n">input1</span><span class="p">),</span> <span class="n">begin</span><span class="p">(</span><span class="n">input2</span><span class="p">),</span> <span class="n">end</span><span class="p">(</span><span class="n">input2</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="s">&quot;input1 &lt; input2 by lexicographical comparison.&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">2*min((last1</span> <span class="pre">-</span> <span class="pre">first1),</span> <span class="pre">(last2</span> <span class="pre">-</span> <span class="pre">first2))</span></tt> applications of the corresponding comparison.</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/lexicographical_compare.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="#">lexicographical_compare</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="#remarks">Remarks</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_element.html"
title="previous chapter">minmax_element</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="tristate_lexicographical_compare.html"
title="next chapter">tristate_lexicographical_compare</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../../_sources/libs/sprout/algorithm/lexicographical_compare.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="tristate_lexicographical_compare.html" title="tristate_lexicographical_compare"
>next</a> |</li>
<li class="right" >
<a href="minmax_element.html" title="minmax_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

@ -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="lexicographical_compare" href="lexicographical_compare.html" />
<link rel="prev" title="max_element" href="max_element.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="lexicographical_compare.html" title="lexicographical_compare"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="max_element.html" title="max_element"
accesskey="P">previous</a> |</li>
@ -118,6 +122,9 @@
<h4>Previous topic</h4>
<p class="topless"><a href="max_element.html"
title="previous chapter">max_element</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="lexicographical_compare.html"
title="next chapter">lexicographical_compare</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../../_sources/libs/sprout/algorithm/minmax_element.txt"
@ -146,6 +153,9 @@
<li class="right" style="margin-right: 10px">
<a href="../../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="lexicographical_compare.html" title="lexicographical_compare"
>next</a> |</li>
<li class="right" >
<a href="max_element.html" title="max_element"
>previous</a> |</li>

View file

@ -62,7 +62,7 @@
<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"><em>true</em> if [first,last) is empty or if <tt class="docutils literal"><span class="pre">pred(*i)</span></tt> is false for every iterator i in the range [first,last), and <em>false</em> otherwise.</div>
<div class="line">true if [first,last) is empty or if <tt class="docutils literal"><span class="pre">pred(*i)</span></tt> is false for every iterator i in the range [first,last), and false otherwise.</div>
</div>
</div>
<div class="section" id="examples">

View file

@ -62,7 +62,7 @@
<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"><em>true</em> if [first,last) is empty or if <tt class="docutils literal"><span class="pre">*i</span> <span class="pre">==</span> <span class="pre">value</span></tt> is false for every iterator i in the range [first,last), and <em>false</em> otherwise.</div>
<div class="line">true if [first,last) is empty or if <tt class="docutils literal"><span class="pre">*i</span> <span class="pre">==</span> <span class="pre">value</span></tt> is false for every iterator i in the range [first,last), and false otherwise.</div>
</div>
</div>
<div class="section" id="examples">

View file

@ -62,7 +62,7 @@
<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"><em>true</em> if [first,last) is not empty and there is only one iterator i in the range [first,last) such that <tt class="docutils literal"><span class="pre">pred(*i)</span></tt> is true, and <em>false</em> otherwise.</div>
<div class="line">true if [first,last) is not empty and there is only one iterator i in the range [first,last) such that <tt class="docutils literal"><span class="pre">pred(*i)</span></tt> is true, and false otherwise.</div>
</div>
</div>
<div class="section" id="examples">

View file

@ -62,7 +62,7 @@
<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"><em>true</em> if [first,last) is not empty and there is only one iterator i in the range [first,last) such that <tt class="docutils literal"><span class="pre">*i</span> <span class="pre">==</span> <span class="pre">value</span></tt> is true, and <em>false</em> otherwise.</div>
<div class="line">true if [first,last) is not empty and there is only one iterator i in the range [first,last) such that <tt class="docutils literal"><span class="pre">*i</span> <span class="pre">==</span> <span class="pre">value</span></tt> is true, and false otherwise.</div>
</div>
</div>
<div class="section" id="examples">

View file

@ -0,0 +1,192 @@
<!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>tristate_lexicographical_compare &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="clamp" href="clamp.html" />
<link rel="prev" title="lexicographical_compare" href="lexicographical_compare.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="clamp.html" title="clamp"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="lexicographical_compare.html" title="lexicographical_compare"
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="tristate-lexicographical-compare">
<h1>tristate_lexicographical_compare<a class="headerlink" href="#tristate-lexicographical-compare" 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">InputIterator1</span><span class="p">,</span> <span class="k">typename</span> <span class="n">InputIterator2</span><span class="o">&gt;</span>
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="kt">int</span>
<span class="n">tristate_lexicographical_compare</span><span class="p">(</span>
<span class="n">InputIterator1</span> <span class="n">first1</span><span class="p">,</span> <span class="n">InputIterator1</span> <span class="n">last1</span><span class="p">,</span>
<span class="n">InputIterator2</span> <span class="n">first2</span><span class="p">,</span> <span class="n">InputIterator2</span> <span class="n">last2</span>
<span class="p">);</span>
<span class="k">template</span><span class="o">&lt;</span><span class="k">typename</span> <span class="n">InputIterator1</span><span class="p">,</span> <span class="k">typename</span> <span class="n">InputIterator2</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="kt">int</span>
<span class="n">tristate_lexicographical_compare</span><span class="p">(</span>
<span class="n">InputIterator1</span> <span class="n">first1</span><span class="p">,</span> <span class="n">InputIterator1</span> <span class="n">last1</span><span class="p">,</span>
<span class="n">InputIterator2</span> <span class="n">first2</span><span class="p">,</span> <span class="n">InputIterator2</span> <span class="n">last2</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">A value less than zero if the sequence of elements defined by the range [first1,last1) is lexicographically less than the sequence of elements defined by the range [first2,last2) and false otherwise.</div>
<div class="line">A value greater than zero if the sequence of elements defined by the range [first1,last1) is lexicographically greater than the sequence of elements defined by the range [first2,last2) and false otherwise.</div>
<div class="line">Otherwise, returns a zero value.</div>
</div>
</div>
<div class="section" id="remarks">
<h2>Remarks<a class="headerlink" href="#remarks" title="Permalink to this headline"></a></h2>
<div class="line-block">
<div class="line">If two sequences have the same number of elements and their corresponding elements are equivalent, then neither sequence is lexicographically less than the other.</div>
<div class="line">If one sequence is a prefix of the other, then the shorter sequence is lexicographically less than the longer sequence.</div>
<div class="line">Otherwise, the lexicographical comparison of the sequences yields the same result as the comparison of the first corresponding pair of elements that are not equivalent.</div>
</div>
<div class="line-block">
<div class="line">An empty sequence is lexicographically less than any non-empty sequence, but not less than any empty sequence.</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/tristate_lexicographical_compare.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">input1</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">input2</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">11</span><span class="p">,</span> <span class="mi">12</span><span class="p">,</span> <span class="mi">13</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">tristate_lexicographical_compare</span><span class="p">(</span><span class="n">begin</span><span class="p">(</span><span class="n">input1</span><span class="p">),</span> <span class="n">end</span><span class="p">(</span><span class="n">input1</span><span class="p">),</span> <span class="n">begin</span><span class="p">(</span><span class="n">input2</span><span class="p">),</span> <span class="n">end</span><span class="p">(</span><span class="n">input2</span><span class="p">));</span>
<span class="n">static_assert</span><span class="p">(</span><span class="n">result</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">,</span> <span class="s">&quot;input1 &lt; input2 by lexicographical comparison.&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">2*min((last1</span> <span class="pre">-</span> <span class="pre">first1),</span> <span class="pre">(last2</span> <span class="pre">-</span> <span class="pre">first2))</span> <span class="pre">+</span> <span class="pre">O(1)</span></tt> applications of the corresponding comparison.</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/tristate_lexicographical_compare.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="#">tristate_lexicographical_compare</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="#remarks">Remarks</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="lexicographical_compare.html"
title="previous chapter">lexicographical_compare</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="clamp.html"
title="next chapter">clamp</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../../_sources/libs/sprout/algorithm/tristate_lexicographical_compare.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="clamp.html" title="clamp"
>next</a> |</li>
<li class="right" >
<a href="lexicographical_compare.html" title="lexicographical_compare"
>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

@ -14,7 +14,7 @@ Interface
Returns
========================================
| *true* if [first,last) is empty or if ``pred(*i)`` is true for every iterator i in the range [first,last), and *false* otherwise.
| true if [first,last) is empty or if ``pred(*i)`` is true for every iterator i in the range [first,last), and false otherwise.
Examples
========================================

View file

@ -14,7 +14,7 @@ Interface
Returns
========================================
| *true* if [first,last) is empty or if ``*i == value`` is true for every iterator i in the range [first,last), and *false* otherwise.
| true if [first,last) is empty or if ``*i == value`` is true for every iterator i in the range [first,last), and false otherwise.
Examples
========================================

View file

@ -14,7 +14,7 @@ Interface
Returns
========================================
| *false* if [first,last) is empty or if there is no iterator i in the range [first,last) such that ``pred(*i)`` is true, and *true* otherwise.
| false if [first,last) is empty or if there is no iterator i in the range [first,last) such that ``pred(*i)`` is true, and true otherwise.
Examples
========================================

View file

@ -14,7 +14,7 @@ Interface
Returns
========================================
| *false* if [first,last) is empty or if there is no iterator i in the range [first,last) such that ``*i == value`` is true, and *true* otherwise.
| false if [first,last) is empty or if there is no iterator i in the range [first,last) such that ``*i == value`` is true, and true otherwise.
Examples
========================================

View file

@ -0,0 +1,57 @@
.. _sprout-algorithm-clamp:
###############################################################################
clamp
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename T>
inline SPROUT_CONSTEXPR T const&
clamp(T const& value, typename sprout::identity<T>::type const& low, typename sprout::identity<T>::type const& high);
template<typename T, typename Compare>
inline SPROUT_CONSTEXPR T const&
clamp(T const& value, typename sprout::identity<T>::type const& low, typename sprout::identity<T>::type const& high, Compare comp);
Requires
========================================
| Type T is LessThanComparable.
Returns
========================================
| low if the following corresponding conditions hold: ``value < low``, ``comp(value, low)``.
| high if the following corresponding conditions hold: ``high < value``, ``comp(high, value)``.
| Otherwise, returns value.
Remarks
========================================
| Using clamp with floating point numbers may give unexpected results if one of the values is NaN.
Complexity
========================================
| Exactly one or two comparisons.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/clamp.hpp>
#include <sprout/array.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{0, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::clamp(20, input[0], input[1]);
static_assert(result == 10, "clamped value is 10.");
Header
========================================
| ``sprout/algorithm/clamp.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -45,6 +45,9 @@ Sprout.Algorithm
min_element
max_element
minmax_element
lexicographical_compare
tristate_lexicographical_compare
clamp
.. _sprout-algorithm-non_modifying:
*******************************************************************************

View file

@ -0,0 +1,72 @@
.. _sprout-algorithm-lexicographical_compare:
###############################################################################
lexicographical_compare
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename InputIterator1, typename InputIterator2>
inline SPROUT_CONSTEXPR bool
lexicographical_compare(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2
);
template<typename InputIterator1, typename InputIterator2, typename Compare>
inline SPROUT_CONSTEXPR bool
lexicographical_compare(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
Compare comp
);
Returns
========================================
| true if the sequence of elements defined by the range [first1,last1) is lexicographically less than the sequence of elements defined by the range [first2,last2) and false otherwise.
Remarks
========================================
| If two sequences have the same number of elements and their corresponding elements are equivalent, then neither sequence is lexicographically less than the other.
| If one sequence is a prefix of the other, then the shorter sequence is lexicographically less than the longer sequence.
| Otherwise, the lexicographical comparison of the sequences yields the same result as the comparison of the first corresponding pair of elements that are not equivalent.
.. sourcecode:: c++
for (; first1 != last1 && first2 != last2; ++first1, ++first2) {
if (*first1 < *first2) return true;
if (*first2 < *first1) return false;
}
return first1 == last1 && first2 != last2;
| An empty sequence is lexicographically less than any non-empty sequence, but not less than any empty sequence.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/lexicographical_compare.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input1 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto input2 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 11, 12, 13}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::lexicographical_compare(begin(input1), end(input1), begin(input2), end(input2));
static_assert(result, "input1 < input2 by lexicographical comparison.");
Complexity
========================================
| At most ``2*min((last1 - first1), (last2 - first2))`` applications of the corresponding comparison.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/lexicographical_compare.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -14,7 +14,7 @@ Interface
Returns
========================================
| *true* if [first,last) is empty or if ``pred(*i)`` is false for every iterator i in the range [first,last), and *false* otherwise.
| true if [first,last) is empty or if ``pred(*i)`` is false for every iterator i in the range [first,last), and false otherwise.
Examples
========================================

View file

@ -14,7 +14,7 @@ Interface
Returns
========================================
| *true* if [first,last) is empty or if ``*i == value`` is false for every iterator i in the range [first,last), and *false* otherwise.
| true if [first,last) is empty or if ``*i == value`` is false for every iterator i in the range [first,last), and false otherwise.
Examples
========================================

View file

@ -14,7 +14,7 @@ Interface
Returns
========================================
| *true* if [first,last) is not empty and there is only one iterator i in the range [first,last) such that ``pred(*i)`` is true, and *false* otherwise.
| true if [first,last) is not empty and there is only one iterator i in the range [first,last) such that ``pred(*i)`` is true, and false otherwise.
Examples
========================================

View file

@ -14,7 +14,7 @@ Interface
Returns
========================================
| *true* if [first,last) is not empty and there is only one iterator i in the range [first,last) such that ``*i == value`` is true, and *false* otherwise.
| true if [first,last) is not empty and there is only one iterator i in the range [first,last) such that ``*i == value`` is true, and false otherwise.
Examples
========================================

View file

@ -0,0 +1,66 @@
.. _sprout-algorithm-tristate_lexicographical_compare:
###############################################################################
tristate_lexicographical_compare
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename InputIterator1, typename InputIterator2>
inline SPROUT_CONSTEXPR int
tristate_lexicographical_compare(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2
);
template<typename InputIterator1, typename InputIterator2, typename Compare>
inline SPROUT_CONSTEXPR int
tristate_lexicographical_compare(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
Compare comp
);
Returns
========================================
| A value less than zero if the sequence of elements defined by the range [first1,last1) is lexicographically less than the sequence of elements defined by the range [first2,last2) and false otherwise.
| A value greater than zero if the sequence of elements defined by the range [first1,last1) is lexicographically greater than the sequence of elements defined by the range [first2,last2) and false otherwise.
| Otherwise, returns a zero value.
Remarks
========================================
| If two sequences have the same number of elements and their corresponding elements are equivalent, then neither sequence is lexicographically less than the other.
| If one sequence is a prefix of the other, then the shorter sequence is lexicographically less than the longer sequence.
| Otherwise, the lexicographical comparison of the sequences yields the same result as the comparison of the first corresponding pair of elements that are not equivalent.
| An empty sequence is lexicographically less than any non-empty sequence, but not less than any empty sequence.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/tristate_lexicographical_compare.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input1 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto input2 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 11, 12, 13}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::tristate_lexicographical_compare(begin(input1), end(input1), begin(input2), end(input2));
static_assert(result < 0, "input1 < input2 by lexicographical comparison.");
Complexity
========================================
| At most ``2*min((last1 - first1), (last2 - first2)) + O(1)`` applications of the corresponding comparison.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/tristate_lexicographical_compare.hpp``
| Convenience header: ``sprout/algorithm.hpp``