mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2024-11-12 21:09:01 +00:00
add doc: find_end, find_first_of, adjacent_find
This commit is contained in:
parent
6f3e65071e
commit
d58e8ce805
22 changed files with 911 additions and 13 deletions
49
docs/_sources/libs/sprout/algorithm/adjacent_find.txt
Normal file
49
docs/_sources/libs/sprout/algorithm/adjacent_find.txt
Normal file
|
@ -0,0 +1,49 @@
|
|||
.. _sprout-algorithm-adjacent_find:
|
||||
###############################################################################
|
||||
adjacent_find
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename ForwardIterator, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR ForwardIterator
|
||||
adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
|
||||
|
||||
template<typename ForwardIterator>
|
||||
inline SPROUT_CONSTEXPR ForwardIterator
|
||||
adjacent_find(ForwardIterator first, ForwardIterator last);
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| The first iterator i such that both i and i + 1 are in the range [first,last) for which the following corresponding conditions hold: ``*i == *(i + 1)``, ``pred(*i, *(i + 1))``.
|
||||
| Returns last if no such iterator is found.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/algorithm/adjacent_find.hpp>
|
||||
#include <sprout/array.hpp>
|
||||
#include <sprout/container.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 5, 5, 6, 6, 8, 9, 10}};
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::adjacent_find(begin(input), end(input));
|
||||
static_assert(result != end(input), "found adjacent elements equal to each other from input.");
|
||||
static_assert(result - begin(input) == 3, "a found position is 3.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| For a nonempty range, exactly ``min((i - first) + 1, (last - first) - 1)`` applications of the corresponding predicate, where i is adjacent_find<6E>fs return value.
|
||||
| Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/algorithm/adjacent_find.hpp``
|
||||
| Convenience header: ``sprout/algorithm.hpp``
|
||||
|
|
@ -29,7 +29,7 @@ Examples
|
|||
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::find(begin(input), end(input), 8);
|
||||
static_assert(result != end(input), "found a element equal to 8 from input.");
|
||||
static_assert(*result == 8, "a found iterator is pointing to 8.");
|
||||
static_assert(result - begin(input1) == 7, "a found position is 7.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
|
62
docs/_sources/libs/sprout/algorithm/find_end.txt
Normal file
62
docs/_sources/libs/sprout/algorithm/find_end.txt
Normal file
|
@ -0,0 +1,62 @@
|
|||
.. _sprout-algorithm-find:
|
||||
###############################################################################
|
||||
find_end
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename ForwardIterator1, typename ForwardIterator2>
|
||||
inline SPROUT_CONSTEXPR ForwardIterator1
|
||||
find_end(
|
||||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2
|
||||
);
|
||||
|
||||
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR ForwardIterator1
|
||||
find_end(
|
||||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
BinaryPredicate pred
|
||||
);
|
||||
|
||||
Effects
|
||||
========================================
|
||||
|
||||
| Finds a subsequence of equal values in a sequence.
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| The last iterator i in the range [first1,last1 - (last2 - first2)) such that for any nonnegative integer ``n < (last2 - first2)``, the following corresponding conditions hold: ``*(i + n) == *(first2 + n)``, ``pred(*(i + n), *(first2 + n))``.
|
||||
| Returns last1 if [first2,last2) is empty or if no such iterator is found.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/algorithm/find_end.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, 1, 2, 3, 4, 5}};
|
||||
SPROUT_STATIC_CONSTEXPR auto input2 = array<int, 3>{{3, 4, 5}};
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::find_end(begin(input1), end(input1), begin(input2), end(input2));
|
||||
static_assert(result != end(input1), "found a subsequence equal to input2 from input1.");
|
||||
static_assert(result - begin(input1) == 7, "a found position is 7.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| At most ``(last2 - first2) * (last1 - first1 - (last2 - first2) + 1)`` applications of the corresponding predicate.
|
||||
| Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/algorithm/find_end.hpp``
|
||||
| Convenience header: ``sprout/algorithm.hpp``
|
||||
|
62
docs/_sources/libs/sprout/algorithm/find_first_of.txt
Normal file
62
docs/_sources/libs/sprout/algorithm/find_first_of.txt
Normal file
|
@ -0,0 +1,62 @@
|
|||
.. _sprout-algorithm-find:
|
||||
###############################################################################
|
||||
find_first_of
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename InputIterator1, typename ForwardIterator2>
|
||||
inline SPROUT_CONSTEXPR InputIterator1
|
||||
find_first_of(
|
||||
InputIterator1 first1, InputIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2
|
||||
);
|
||||
|
||||
template<typename InputIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR InputIterator1
|
||||
find_first_of(
|
||||
InputIterator1 first1, InputIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
BinaryPredicate pred
|
||||
);
|
||||
|
||||
Effects
|
||||
========================================
|
||||
|
||||
| Finds an element that matches one of a set of values.
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| The first iterator i in the range [first1,last1) such that for some iterator j in the range [first2,last2) the following conditions hold: ``*i == *j``, ``pred(*i,*j)``.
|
||||
| Returns last1 if [first2,last2) is empty or if no such iterator is found.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/algorithm/find_first_of.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, 1, 2, 3, 4, 5}};
|
||||
SPROUT_STATIC_CONSTEXPR auto input2 = array<int, 3>{{3, 4, 5}};
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::find_first_of(begin(input1), end(input1), begin(input2), end(input2));
|
||||
static_assert(result != end(input1), "found an element equal to an one of input2 from input1.");
|
||||
static_assert(result - begin(input1) == 2, "a found position is 2.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| At most ``(last2 - first2) * (last1 - first1 - (last2 - first2) + 1)`` applications of the corresponding predicate.
|
||||
| Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/algorithm/find_first_of.hpp``
|
||||
| Convenience header: ``sprout/algorithm.hpp``
|
||||
|
|
@ -30,7 +30,7 @@ Examples
|
|||
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::find_if(begin(input), end(input), bind2nd(greater<>(), 7));
|
||||
static_assert(result != end(input), "found a element greater than 7 from input.");
|
||||
static_assert(*result == 8, "a found iterator is pointing to 8.");
|
||||
static_assert(result - begin(input1) == 7, "a found position is 7.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
|
|
@ -30,7 +30,7 @@ Examples
|
|||
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::find_if_not(begin(input), end(input), bind2nd(less<>(), 8));
|
||||
static_assert(result != end(input), "found a element not less than 8 from input.");
|
||||
static_assert(*result == 8, "a found iterator is pointing to 8.");
|
||||
static_assert(result - begin(input1) == 7, "a found position is 7.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
|
|
@ -17,6 +17,9 @@ Sprout.Algorithm
|
|||
find
|
||||
find_if
|
||||
find_if_not
|
||||
find_end
|
||||
find_first_of
|
||||
adjacent_find
|
||||
|
||||
.. _sprout-algorithm-non_modifying:
|
||||
*******************************************************************************
|
||||
|
|
162
docs/libs/sprout/algorithm/adjacent_find.html
Normal file
162
docs/libs/sprout/algorithm/adjacent_find.html
Normal file
|
@ -0,0 +1,162 @@
|
|||
<!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>adjacent_find — 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="find_first_of" href="find_first_of.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="find_first_of.html" title="find_first_of"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li><a href="../../../index.html">Sprout v1.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Sprout C++ Libraries</a> »</li>
|
||||
<li><a href="../../libraries.html" >Libraries</a> »</li>
|
||||
<li><a href="index.html" accesskey="U">Sprout.Algorithm</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<div class="section" id="adjacent-find">
|
||||
<h1>adjacent_find<a class="headerlink" href="#adjacent-find" 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"><</span><span class="k">typename</span> <span class="n">ForwardIterator</span><span class="p">,</span> <span class="k">typename</span> <span class="n">BinaryPredicate</span><span class="o">></span>
|
||||
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="n">ForwardIterator</span>
|
||||
<span class="n">adjacent_find</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">BinaryPredicate</span> <span class="n">pred</span><span class="p">);</span>
|
||||
|
||||
<span class="k">template</span><span class="o"><</span><span class="k">typename</span> <span class="n">ForwardIterator</span><span class="o">></span>
|
||||
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="n">ForwardIterator</span>
|
||||
<span class="n">adjacent_find</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>
|
||||
</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 such that both i and i + 1 are in the range [first,last) for which the following corresponding conditions hold: <tt class="docutils literal"><span class="pre">*i</span> <span class="pre">==</span> <span class="pre">*(i</span> <span class="pre">+</span> <span class="pre">1)</span></tt>, <tt class="docutils literal"><span class="pre">pred(*i,</span> <span class="pre">*(i</span> <span class="pre">+</span> <span class="pre">1))</span></tt>.</div>
|
||||
<div class="line">Returns last if no such iterator is found.</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 <sprout/algorithm/adjacent_find.hpp></span>
|
||||
<span class="cp">#include <sprout/array.hpp></span>
|
||||
<span class="cp">#include <sprout/container.hpp></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"><</span><span class="kt">int</span><span class="p">,</span> <span class="mi">10</span><span class="o">></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">5</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">6</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">adjacent_find</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="n">result</span> <span class="o">!=</span> <span class="n">end</span><span class="p">(</span><span class="n">input</span><span class="p">),</span> <span class="s">"found adjacent elements equal to each other from input."</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">3</span><span class="p">,</span> <span class="s">"a found position is 3."</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">For a nonempty range, exactly <tt class="docutils literal"><span class="pre">min((i</span> <span class="pre">-</span> <span class="pre">first)</span> <span class="pre">+</span> <span class="pre">1,</span> <span class="pre">(last</span> <span class="pre">-</span> <span class="pre">first)</span> <span class="pre">-</span> <span class="pre">1)</span></tt> applications of the corresponding predicate, where i is adjacent_find?fs return value.</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/adjacent_find.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="#">adjacent_find</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="find_first_of.html"
|
||||
title="previous chapter">find_first_of</a></p>
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="../../../_sources/libs/sprout/algorithm/adjacent_find.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="find_first_of.html" title="find_first_of"
|
||||
>previous</a> |</li>
|
||||
<li><a href="../../../index.html">Sprout v1.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Sprout C++ Libraries</a> »</li>
|
||||
<li><a href="../../libraries.html" >Libraries</a> »</li>
|
||||
<li><a href="index.html" >Sprout.Algorithm</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2013, Bolero MURAKAMI.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.4.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -76,7 +76,7 @@
|
|||
<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"><</span><span class="kt">int</span><span class="p">,</span> <span class="mi">10</span><span class="o">></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">find</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="mi">8</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">end</span><span class="p">(</span><span class="n">input</span><span class="p">),</span> <span class="s">"found a element equal to 8 from 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">8</span><span class="p">,</span> <span class="s">"a found iterator is pointing to 8."</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">input1</span><span class="p">)</span> <span class="o">==</span> <span class="mi">7</span><span class="p">,</span> <span class="s">"a found position is 7."</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
187
docs/libs/sprout/algorithm/find_end.html
Normal file
187
docs/libs/sprout/algorithm/find_end.html
Normal file
|
@ -0,0 +1,187 @@
|
|||
<!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>find_end — 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="find_first_of" href="find_first_of.html" />
|
||||
<link rel="prev" title="find_if_not" href="find_if_not.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="find_first_of.html" title="find_first_of"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="find_if_not.html" title="find_if_not"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li><a href="../../../index.html">Sprout v1.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Sprout C++ Libraries</a> »</li>
|
||||
<li><a href="../../libraries.html" >Libraries</a> »</li>
|
||||
<li><a href="index.html" accesskey="U">Sprout.Algorithm</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<div class="section" id="find-end">
|
||||
<h1>find_end<a class="headerlink" href="#find-end" 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"><</span><span class="k">typename</span> <span class="n">ForwardIterator1</span><span class="p">,</span> <span class="k">typename</span> <span class="n">ForwardIterator2</span><span class="o">></span>
|
||||
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="n">ForwardIterator1</span>
|
||||
<span class="n">find_end</span><span class="p">(</span>
|
||||
<span class="n">ForwardIterator1</span> <span class="n">first1</span><span class="p">,</span> <span class="n">ForwardIterator1</span> <span class="n">last1</span><span class="p">,</span>
|
||||
<span class="n">ForwardIterator2</span> <span class="n">first2</span><span class="p">,</span> <span class="n">ForwardIterator2</span> <span class="n">last2</span>
|
||||
<span class="p">);</span>
|
||||
|
||||
<span class="k">template</span><span class="o"><</span><span class="k">typename</span> <span class="n">ForwardIterator1</span><span class="p">,</span> <span class="k">typename</span> <span class="n">ForwardIterator2</span><span class="p">,</span> <span class="k">typename</span> <span class="n">BinaryPredicate</span><span class="o">></span>
|
||||
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="n">ForwardIterator1</span>
|
||||
<span class="n">find_end</span><span class="p">(</span>
|
||||
<span class="n">ForwardIterator1</span> <span class="n">first1</span><span class="p">,</span> <span class="n">ForwardIterator1</span> <span class="n">last1</span><span class="p">,</span>
|
||||
<span class="n">ForwardIterator2</span> <span class="n">first2</span><span class="p">,</span> <span class="n">ForwardIterator2</span> <span class="n">last2</span><span class="p">,</span>
|
||||
<span class="n">BinaryPredicate</span> <span class="n">pred</span>
|
||||
<span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="effects">
|
||||
<h2>Effects<a class="headerlink" href="#effects" title="Permalink to this headline">¶</a></h2>
|
||||
<div class="line-block">
|
||||
<div class="line">Finds a subsequence of equal values in a sequence.</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 last iterator i in the range [first1,last1 - (last2 - first2)) such that for any nonnegative integer <tt class="docutils literal"><span class="pre">n</span> <span class="pre"><</span> <span class="pre">(last2</span> <span class="pre">-</span> <span class="pre">first2)</span></tt>, the following corresponding conditions hold: <tt class="docutils literal"><span class="pre">*(i</span> <span class="pre">+</span> <span class="pre">n)</span> <span class="pre">==</span> <span class="pre">*(first2</span> <span class="pre">+</span> <span class="pre">n)</span></tt>, <tt class="docutils literal"><span class="pre">pred(*(i</span> <span class="pre">+</span> <span class="pre">n),</span> <span class="pre">*(first2</span> <span class="pre">+</span> <span class="pre">n))</span></tt>.</div>
|
||||
<div class="line">Returns last1 if [first2,last2) is empty or if no such iterator is found.</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 <sprout/algorithm/find_end.hpp></span>
|
||||
<span class="cp">#include <sprout/array.hpp></span>
|
||||
<span class="cp">#include <sprout/container.hpp></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"><</span><span class="kt">int</span><span class="p">,</span> <span class="mi">10</span><span class="o">></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">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="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"><</span><span class="kt">int</span><span class="p">,</span> <span class="mi">3</span><span class="o">></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="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">find_end</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">!=</span> <span class="n">end</span><span class="p">(</span><span class="n">input1</span><span class="p">),</span> <span class="s">"found a subsequence equal to input2 from input1."</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">input1</span><span class="p">)</span> <span class="o">==</span> <span class="mi">7</span><span class="p">,</span> <span class="s">"a found position is 7."</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">(last2</span> <span class="pre">-</span> <span class="pre">first2)</span> <span class="pre">*</span> <span class="pre">(last1</span> <span class="pre">-</span> <span class="pre">first1</span> <span class="pre">-</span> <span class="pre">(last2</span> <span class="pre">-</span> <span class="pre">first2)</span> <span class="pre">+</span> <span class="pre">1)</span></tt> applications of the corresponding predicate.</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/find_end.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="#">find_end</a><ul>
|
||||
<li><a class="reference external" href="#interface">Interface</a></li>
|
||||
<li><a class="reference external" href="#effects">Effects</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="find_if_not.html"
|
||||
title="previous chapter">find_if_not</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="find_first_of.html"
|
||||
title="next chapter">find_first_of</a></p>
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="../../../_sources/libs/sprout/algorithm/find_end.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="find_first_of.html" title="find_first_of"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="find_if_not.html" title="find_if_not"
|
||||
>previous</a> |</li>
|
||||
<li><a href="../../../index.html">Sprout v1.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Sprout C++ Libraries</a> »</li>
|
||||
<li><a href="../../libraries.html" >Libraries</a> »</li>
|
||||
<li><a href="index.html" >Sprout.Algorithm</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2013, Bolero MURAKAMI.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.4.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
187
docs/libs/sprout/algorithm/find_first_of.html
Normal file
187
docs/libs/sprout/algorithm/find_first_of.html
Normal file
|
@ -0,0 +1,187 @@
|
|||
<!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>find_first_of — 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="adjacent_find" href="adjacent_find.html" />
|
||||
<link rel="prev" title="find_end" href="find_end.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="adjacent_find.html" title="adjacent_find"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="find_end.html" title="find_end"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li><a href="../../../index.html">Sprout v1.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Sprout C++ Libraries</a> »</li>
|
||||
<li><a href="../../libraries.html" >Libraries</a> »</li>
|
||||
<li><a href="index.html" accesskey="U">Sprout.Algorithm</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<div class="section" id="find-first-of">
|
||||
<h1>find_first_of<a class="headerlink" href="#find-first-of" 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"><</span><span class="k">typename</span> <span class="n">InputIterator1</span><span class="p">,</span> <span class="k">typename</span> <span class="n">ForwardIterator2</span><span class="o">></span>
|
||||
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="n">InputIterator1</span>
|
||||
<span class="n">find_first_of</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">ForwardIterator2</span> <span class="n">first2</span><span class="p">,</span> <span class="n">ForwardIterator2</span> <span class="n">last2</span>
|
||||
<span class="p">);</span>
|
||||
|
||||
<span class="k">template</span><span class="o"><</span><span class="k">typename</span> <span class="n">InputIterator1</span><span class="p">,</span> <span class="k">typename</span> <span class="n">ForwardIterator2</span><span class="p">,</span> <span class="k">typename</span> <span class="n">BinaryPredicate</span><span class="o">></span>
|
||||
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="n">InputIterator1</span>
|
||||
<span class="n">find_first_of</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">ForwardIterator2</span> <span class="n">first2</span><span class="p">,</span> <span class="n">ForwardIterator2</span> <span class="n">last2</span><span class="p">,</span>
|
||||
<span class="n">BinaryPredicate</span> <span class="n">pred</span>
|
||||
<span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="effects">
|
||||
<h2>Effects<a class="headerlink" href="#effects" title="Permalink to this headline">¶</a></h2>
|
||||
<div class="line-block">
|
||||
<div class="line">Finds an element that matches one of a set of values.</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 [first1,last1) such that for some iterator j in the range [first2,last2) the following conditions hold: <tt class="docutils literal"><span class="pre">*i</span> <span class="pre">==</span> <span class="pre">*j</span></tt>, <tt class="docutils literal"><span class="pre">pred(*i,*j)</span></tt>.</div>
|
||||
<div class="line">Returns last1 if [first2,last2) is empty or if no such iterator is found.</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 <sprout/algorithm/find_first_of.hpp></span>
|
||||
<span class="cp">#include <sprout/array.hpp></span>
|
||||
<span class="cp">#include <sprout/container.hpp></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"><</span><span class="kt">int</span><span class="p">,</span> <span class="mi">10</span><span class="o">></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">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="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"><</span><span class="kt">int</span><span class="p">,</span> <span class="mi">3</span><span class="o">></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="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">find_first_of</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">!=</span> <span class="n">end</span><span class="p">(</span><span class="n">input1</span><span class="p">),</span> <span class="s">"found an element equal to an one of input2 from input1."</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">input1</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">,</span> <span class="s">"a found position is 2."</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">(last2</span> <span class="pre">-</span> <span class="pre">first2)</span> <span class="pre">*</span> <span class="pre">(last1</span> <span class="pre">-</span> <span class="pre">first1</span> <span class="pre">-</span> <span class="pre">(last2</span> <span class="pre">-</span> <span class="pre">first2)</span> <span class="pre">+</span> <span class="pre">1)</span></tt> applications of the corresponding predicate.</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/find_first_of.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="#">find_first_of</a><ul>
|
||||
<li><a class="reference external" href="#interface">Interface</a></li>
|
||||
<li><a class="reference external" href="#effects">Effects</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="find_end.html"
|
||||
title="previous chapter">find_end</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="adjacent_find.html"
|
||||
title="next chapter">adjacent_find</a></p>
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="../../../_sources/libs/sprout/algorithm/find_first_of.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="adjacent_find.html" title="adjacent_find"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="find_end.html" title="find_end"
|
||||
>previous</a> |</li>
|
||||
<li><a href="../../../index.html">Sprout v1.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Sprout C++ Libraries</a> »</li>
|
||||
<li><a href="../../libraries.html" >Libraries</a> »</li>
|
||||
<li><a href="index.html" >Sprout.Algorithm</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2013, Bolero MURAKAMI.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.4.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -77,7 +77,7 @@
|
|||
<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"><</span><span class="kt">int</span><span class="p">,</span> <span class="mi">10</span><span class="o">></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">find_if</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">bind2nd</span><span class="p">(</span><span class="n">greater</span><span class="o"><></span><span class="p">(),</span> <span class="mi">7</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">end</span><span class="p">(</span><span class="n">input</span><span class="p">),</span> <span class="s">"found a element greater than 7 from 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">8</span><span class="p">,</span> <span class="s">"a found iterator is pointing to 8."</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">input1</span><span class="p">)</span> <span class="o">==</span> <span class="mi">7</span><span class="p">,</span> <span class="s">"a found position is 7."</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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="find_end" href="find_end.html" />
|
||||
<link rel="prev" title="find_if" href="find_if.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="find_end.html" title="find_end"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="find_if.html" title="find_if"
|
||||
accesskey="P">previous</a> |</li>
|
||||
|
@ -73,7 +77,7 @@
|
|||
<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"><</span><span class="kt">int</span><span class="p">,</span> <span class="mi">10</span><span class="o">></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">find_if_not</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">bind2nd</span><span class="p">(</span><span class="n">less</span><span class="o"><></span><span class="p">(),</span> <span class="mi">8</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">end</span><span class="p">(</span><span class="n">input</span><span class="p">),</span> <span class="s">"found a element not less than 8 from 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">8</span><span class="p">,</span> <span class="s">"a found iterator is pointing to 8."</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">input1</span><span class="p">)</span> <span class="o">==</span> <span class="mi">7</span><span class="p">,</span> <span class="s">"a found position is 7."</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -114,6 +118,9 @@
|
|||
<h4>Previous topic</h4>
|
||||
<p class="topless"><a href="find_if.html"
|
||||
title="previous chapter">find_if</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="find_end.html"
|
||||
title="next chapter">find_end</a></p>
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="../../../_sources/libs/sprout/algorithm/find_if_not.txt"
|
||||
|
@ -142,6 +149,9 @@
|
|||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="find_end.html" title="find_end"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="find_if.html" title="find_if"
|
||||
>previous</a> |</li>
|
||||
|
|
|
@ -64,9 +64,9 @@
|
|||
<li><a class="reference external" href="find.html"><em>find</em></a></li>
|
||||
<li><a class="reference external" href="find_if.html"><em>find_if</em></a></li>
|
||||
<li><a class="reference external" href="find_if_not.html"><em>find_if_not</em></a></li>
|
||||
<li><tt class="xref docutils literal"><span class="pre">find_end</span></tt></li>
|
||||
<li><tt class="xref docutils literal"><span class="pre">find_first_of</span></tt></li>
|
||||
<li><tt class="xref docutils literal"><span class="pre">adjacent_find</span></tt></li>
|
||||
<li><a class="reference external" href="find_end.html"><em>find_end</em></a></li>
|
||||
<li><a class="reference external" href="find_first_of.html"><em>find_first_of</em></a></li>
|
||||
<li><a class="reference external" href="adjacent_find.html"><em>adjacent_find</em></a></li>
|
||||
<li><tt class="xref docutils literal"><span class="pre">count</span></tt></li>
|
||||
<li><tt class="xref docutils literal"><span class="pre">count_if</span></tt></li>
|
||||
<li><tt class="xref docutils literal"><span class="pre">mismatch</span></tt></li>
|
||||
|
|
File diff suppressed because one or more lines are too long
49
source/libs/sprout/algorithm/adjacent_find.rst
Normal file
49
source/libs/sprout/algorithm/adjacent_find.rst
Normal file
|
@ -0,0 +1,49 @@
|
|||
.. _sprout-algorithm-adjacent_find:
|
||||
###############################################################################
|
||||
adjacent_find
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename ForwardIterator, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR ForwardIterator
|
||||
adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
|
||||
|
||||
template<typename ForwardIterator>
|
||||
inline SPROUT_CONSTEXPR ForwardIterator
|
||||
adjacent_find(ForwardIterator first, ForwardIterator last);
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| The first iterator i such that both i and i + 1 are in the range [first,last) for which the following corresponding conditions hold: ``*i == *(i + 1)``, ``pred(*i, *(i + 1))``.
|
||||
| Returns last if no such iterator is found.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/algorithm/adjacent_find.hpp>
|
||||
#include <sprout/array.hpp>
|
||||
#include <sprout/container.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 5, 5, 6, 6, 8, 9, 10}};
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::adjacent_find(begin(input), end(input));
|
||||
static_assert(result != end(input), "found adjacent elements equal to each other from input.");
|
||||
static_assert(result - begin(input) == 3, "a found position is 3.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| For a nonempty range, exactly ``min((i - first) + 1, (last - first) - 1)`` applications of the corresponding predicate, where i is adjacent_find<6E>fs return value.
|
||||
| Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/algorithm/adjacent_find.hpp``
|
||||
| Convenience header: ``sprout/algorithm.hpp``
|
||||
|
|
@ -29,7 +29,7 @@ Examples
|
|||
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::find(begin(input), end(input), 8);
|
||||
static_assert(result != end(input), "found a element equal to 8 from input.");
|
||||
static_assert(*result == 8, "a found iterator is pointing to 8.");
|
||||
static_assert(result - begin(input1) == 7, "a found position is 7.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
|
62
source/libs/sprout/algorithm/find_end.rst
Normal file
62
source/libs/sprout/algorithm/find_end.rst
Normal file
|
@ -0,0 +1,62 @@
|
|||
.. _sprout-algorithm-find:
|
||||
###############################################################################
|
||||
find_end
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename ForwardIterator1, typename ForwardIterator2>
|
||||
inline SPROUT_CONSTEXPR ForwardIterator1
|
||||
find_end(
|
||||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2
|
||||
);
|
||||
|
||||
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR ForwardIterator1
|
||||
find_end(
|
||||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
BinaryPredicate pred
|
||||
);
|
||||
|
||||
Effects
|
||||
========================================
|
||||
|
||||
| Finds a subsequence of equal values in a sequence.
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| The last iterator i in the range [first1,last1 - (last2 - first2)) such that for any nonnegative integer ``n < (last2 - first2)``, the following corresponding conditions hold: ``*(i + n) == *(first2 + n)``, ``pred(*(i + n), *(first2 + n))``.
|
||||
| Returns last1 if [first2,last2) is empty or if no such iterator is found.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/algorithm/find_end.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, 1, 2, 3, 4, 5}};
|
||||
SPROUT_STATIC_CONSTEXPR auto input2 = array<int, 3>{{3, 4, 5}};
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::find_end(begin(input1), end(input1), begin(input2), end(input2));
|
||||
static_assert(result != end(input1), "found a subsequence equal to input2 from input1.");
|
||||
static_assert(result - begin(input1) == 7, "a found position is 7.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| At most ``(last2 - first2) * (last1 - first1 - (last2 - first2) + 1)`` applications of the corresponding predicate.
|
||||
| Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/algorithm/find_end.hpp``
|
||||
| Convenience header: ``sprout/algorithm.hpp``
|
||||
|
62
source/libs/sprout/algorithm/find_first_of.rst
Normal file
62
source/libs/sprout/algorithm/find_first_of.rst
Normal file
|
@ -0,0 +1,62 @@
|
|||
.. _sprout-algorithm-find:
|
||||
###############################################################################
|
||||
find_first_of
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename InputIterator1, typename ForwardIterator2>
|
||||
inline SPROUT_CONSTEXPR InputIterator1
|
||||
find_first_of(
|
||||
InputIterator1 first1, InputIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2
|
||||
);
|
||||
|
||||
template<typename InputIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR InputIterator1
|
||||
find_first_of(
|
||||
InputIterator1 first1, InputIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
BinaryPredicate pred
|
||||
);
|
||||
|
||||
Effects
|
||||
========================================
|
||||
|
||||
| Finds an element that matches one of a set of values.
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| The first iterator i in the range [first1,last1) such that for some iterator j in the range [first2,last2) the following conditions hold: ``*i == *j``, ``pred(*i,*j)``.
|
||||
| Returns last1 if [first2,last2) is empty or if no such iterator is found.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/algorithm/find_first_of.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, 1, 2, 3, 4, 5}};
|
||||
SPROUT_STATIC_CONSTEXPR auto input2 = array<int, 3>{{3, 4, 5}};
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::find_first_of(begin(input1), end(input1), begin(input2), end(input2));
|
||||
static_assert(result != end(input1), "found an element equal to an one of input2 from input1.");
|
||||
static_assert(result - begin(input1) == 2, "a found position is 2.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| At most ``(last2 - first2) * (last1 - first1 - (last2 - first2) + 1)`` applications of the corresponding predicate.
|
||||
| Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/algorithm/find_first_of.hpp``
|
||||
| Convenience header: ``sprout/algorithm.hpp``
|
||||
|
|
@ -30,7 +30,7 @@ Examples
|
|||
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::find_if(begin(input), end(input), bind2nd(greater<>(), 7));
|
||||
static_assert(result != end(input), "found a element greater than 7 from input.");
|
||||
static_assert(*result == 8, "a found iterator is pointing to 8.");
|
||||
static_assert(result - begin(input1) == 7, "a found position is 7.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
|
|
@ -30,7 +30,7 @@ Examples
|
|||
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::find_if_not(begin(input), end(input), bind2nd(less<>(), 8));
|
||||
static_assert(result != end(input), "found a element not less than 8 from input.");
|
||||
static_assert(*result == 8, "a found iterator is pointing to 8.");
|
||||
static_assert(result - begin(input1) == 7, "a found position is 7.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
|
|
@ -17,6 +17,9 @@ Sprout.Algorithm
|
|||
find
|
||||
find_if
|
||||
find_if_not
|
||||
find_end
|
||||
find_first_of
|
||||
adjacent_find
|
||||
|
||||
.. _sprout-algorithm-non_modifying:
|
||||
*******************************************************************************
|
||||
|
|
Loading…
Reference in a new issue