mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-02-04 21:33:56 +00:00
add none_of, one_of
This commit is contained in:
parent
093ec715de
commit
3b0fde550d
15 changed files with 530 additions and 10 deletions
|
@ -21,7 +21,7 @@ Containers and Data structures
|
|||
Algorithms
|
||||
=======================================
|
||||
|
||||
* :doc:`algorithm <./sprout/algorithm/index>`
|
||||
* :doc:`algorithm <./sprout/algorithm/index>` - STL-like generic algorithms.
|
||||
|
||||
.. _sprout-listed_by_category-algorithms:
|
||||
Algorithms
|
||||
|
|
|
@ -8,6 +8,8 @@ Sprout.Algorithm
|
|||
|
||||
all_of
|
||||
any_of
|
||||
none_of
|
||||
one_of
|
||||
|
||||
.. _sprout-algorithm-non_modifying:
|
||||
*******************************************************************************
|
||||
|
@ -18,3 +20,7 @@ Non-modifying sequence operations
|
|||
|
||||
* :doc:`./any_of`
|
||||
|
||||
* :doc:`./none_of`
|
||||
|
||||
* :doc:`./one_of`
|
||||
|
||||
|
|
46
docs/_sources/libs/sprout/algorithm/none_of.txt
Normal file
46
docs/_sources/libs/sprout/algorithm/none_of.txt
Normal file
|
@ -0,0 +1,46 @@
|
|||
.. _sprout-algorithm-none_of:
|
||||
###############################################################################
|
||||
none_of
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
none_of(InputIterator first, InputIterator last, Predicate pred);
|
||||
|
||||
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.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/algorithm/none_of.hpp>
|
||||
#include <sprout/array.hpp>
|
||||
#include <sprout/container.hpp>
|
||||
#include <sprout/functional.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::none_of(begin(input), end(input), bind2nd(greater<>(), 10));
|
||||
static_assert(result, "none of input is greater than 10.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
At most ``last - first`` applications of the predicate.
|
||||
|
||||
Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
``sprout/algorithm/none_of.hpp``
|
||||
|
||||
Convenience header: ``sprout/algorithm.hpp``
|
||||
|
46
docs/_sources/libs/sprout/algorithm/one_of.txt
Normal file
46
docs/_sources/libs/sprout/algorithm/one_of.txt
Normal file
|
@ -0,0 +1,46 @@
|
|||
.. _sprout-algorithm-one_of:
|
||||
###############################################################################
|
||||
one_of
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
one_of(InputIterator first, InputIterator last, Predicate pred);
|
||||
|
||||
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.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/algorithm/one_of.hpp>
|
||||
#include <sprout/array.hpp>
|
||||
#include <sprout/container.hpp>
|
||||
#include <sprout/functional.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::one_of(begin(input), end(input), bind2nd(greater<>(), 9));
|
||||
static_assert(result, "one of input is greater than 9.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
At most ``last - first`` applications of the predicate.
|
||||
|
||||
Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
``sprout/algorithm/one_of.hpp``
|
||||
|
||||
Convenience header: ``sprout/algorithm.hpp``
|
||||
|
|
@ -57,7 +57,7 @@
|
|||
<div class="section" id="algorithms">
|
||||
<h3>Algorithms<a class="headerlink" href="#algorithms" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><a class="reference external" href="sprout/algorithm/index.html"><em>algorithm</em></a></li>
|
||||
<li><a class="reference external" href="sprout/algorithm/index.html"><em>algorithm</em></a> - STL-like generic algorithms.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="id2">
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<a href="index.html" title="Sprout.Algorithm"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li><a href="../../../index.html">Sprout v1.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Sprout C++ Library</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>
|
||||
|
@ -148,7 +148,7 @@
|
|||
<a href="index.html" title="Sprout.Algorithm"
|
||||
>previous</a> |</li>
|
||||
<li><a href="../../../index.html">Sprout v1.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Sprout C++ Library</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>
|
||||
|
|
|
@ -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="none_of" href="none_of.html" />
|
||||
<link rel="prev" title="all_of" href="all_of.html" />
|
||||
</head>
|
||||
<body>
|
||||
|
@ -30,11 +31,14 @@
|
|||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="none_of.html" title="none_of"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="all_of.html" title="all_of"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li><a href="../../../index.html">Sprout v1.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Sprout C++ Library</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>
|
||||
|
@ -106,6 +110,9 @@
|
|||
<h4>Previous topic</h4>
|
||||
<p class="topless"><a href="all_of.html"
|
||||
title="previous chapter">all_of</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="none_of.html"
|
||||
title="next chapter">none_of</a></p>
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="../../../_sources/libs/sprout/algorithm/any_of.txt"
|
||||
|
@ -134,11 +141,14 @@
|
|||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="none_of.html" title="none_of"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="all_of.html" title="all_of"
|
||||
>previous</a> |</li>
|
||||
<li><a href="../../../index.html">Sprout v1.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Sprout C++ Library</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>
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<a href="../../libraries.html" title="Libraries"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li><a href="../../../index.html">Sprout v1.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Sprout C++ Library</a> »</li>
|
||||
<li><a href="../../index.html" >Sprout C++ Libraries</a> »</li>
|
||||
<li><a href="../../libraries.html" accesskey="U">Libraries</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -55,6 +55,8 @@
|
|||
<ul class="simple">
|
||||
<li><a class="reference external" href="all_of.html"><em>all_of</em></a></li>
|
||||
<li><a class="reference external" href="any_of.html"><em>any_of</em></a></li>
|
||||
<li><a class="reference external" href="none_of.html"><em>none_of</em></a></li>
|
||||
<li><a class="reference external" href="one_of.html"><em>one_of</em></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -114,7 +116,7 @@
|
|||
<a href="../../libraries.html" title="Libraries"
|
||||
>previous</a> |</li>
|
||||
<li><a href="../../../index.html">Sprout v1.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Sprout C++ Library</a> »</li>
|
||||
<li><a href="../../index.html" >Sprout C++ Libraries</a> »</li>
|
||||
<li><a href="../../libraries.html" >Libraries</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
161
docs/libs/sprout/algorithm/none_of.html
Normal file
161
docs/libs/sprout/algorithm/none_of.html
Normal file
|
@ -0,0 +1,161 @@
|
|||
<!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>none_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="one_of" href="one_of.html" />
|
||||
<link rel="prev" title="any_of" href="any_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="one_of.html" title="one_of"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="any_of.html" title="any_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="none-of">
|
||||
<h1>none_of<a class="headerlink" href="#none-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">InputIterator</span><span class="p">,</span> <span class="k">typename</span> <span class="n">Predicate</span><span class="o">></span>
|
||||
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="kt">bool</span>
|
||||
<span class="n">none_of</span><span class="p">(</span><span class="n">InputIterator</span> <span class="n">first</span><span class="p">,</span> <span class="n">InputIterator</span> <span class="n">last</span><span class="p">,</span> <span class="n">Predicate</span> <span class="n">pred</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>
|
||||
<p><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.</p>
|
||||
</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/none_of.hpp></span>
|
||||
<span class="cp">#include <sprout/array.hpp></span>
|
||||
<span class="cp">#include <sprout/container.hpp></span>
|
||||
<span class="cp">#include <sprout/functional.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">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">none_of</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">10</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">"none of input is greater than 10."</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>
|
||||
<p>At most <tt class="docutils literal"><span class="pre">last</span> <span class="pre">-</span> <span class="pre">first</span></tt> applications of the predicate.</p>
|
||||
<p>Recursive function invocations in <em>O(logN)</em> (logarithmic) depth.</p>
|
||||
</div>
|
||||
<div class="section" id="header">
|
||||
<h2>Header<a class="headerlink" href="#header" title="Permalink to this headline">¶</a></h2>
|
||||
<p><tt class="docutils literal"><span class="pre">sprout/algorithm/none_of.hpp</span></tt></p>
|
||||
<p>Convenience header: <tt class="docutils literal"><span class="pre">sprout/algorithm.hpp</span></tt></p>
|
||||
</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="#">none_of</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="any_of.html"
|
||||
title="previous chapter">any_of</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="one_of.html"
|
||||
title="next chapter">one_of</a></p>
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="../../../_sources/libs/sprout/algorithm/none_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="one_of.html" title="one_of"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="any_of.html" title="any_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>
|
151
docs/libs/sprout/algorithm/one_of.html
Normal file
151
docs/libs/sprout/algorithm/one_of.html
Normal file
|
@ -0,0 +1,151 @@
|
|||
<!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>one_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="prev" title="none_of" href="none_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="none_of.html" title="none_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="one-of">
|
||||
<h1>one_of<a class="headerlink" href="#one-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">InputIterator</span><span class="p">,</span> <span class="k">typename</span> <span class="n">Predicate</span><span class="o">></span>
|
||||
<span class="kr">inline</span> <span class="n">SPROUT_CONSTEXPR</span> <span class="kt">bool</span>
|
||||
<span class="n">one_of</span><span class="p">(</span><span class="n">InputIterator</span> <span class="n">first</span><span class="p">,</span> <span class="n">InputIterator</span> <span class="n">last</span><span class="p">,</span> <span class="n">Predicate</span> <span class="n">pred</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>
|
||||
<p><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.</p>
|
||||
</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/one_of.hpp></span>
|
||||
<span class="cp">#include <sprout/array.hpp></span>
|
||||
<span class="cp">#include <sprout/container.hpp></span>
|
||||
<span class="cp">#include <sprout/functional.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">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">one_of</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">9</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">"one of input is greater than 9."</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>
|
||||
<p>At most <tt class="docutils literal"><span class="pre">last</span> <span class="pre">-</span> <span class="pre">first</span></tt> applications of the predicate.</p>
|
||||
<p>Recursive function invocations in <em>O(logN)</em> (logarithmic) depth.</p>
|
||||
</div>
|
||||
<div class="section" id="header">
|
||||
<h2>Header<a class="headerlink" href="#header" title="Permalink to this headline">¶</a></h2>
|
||||
<p><tt class="docutils literal"><span class="pre">sprout/algorithm/one_of.hpp</span></tt></p>
|
||||
<p>Convenience header: <tt class="docutils literal"><span class="pre">sprout/algorithm.hpp</span></tt></p>
|
||||
</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="#">one_of</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="none_of.html"
|
||||
title="previous chapter">none_of</a></p>
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="../../../_sources/libs/sprout/algorithm/one_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="none_of.html" title="none_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>
|
|
@ -1 +1 @@
|
|||
Search.setIndex({desctypes:{},terms:{any_of:[0,2],all:5,less:5,sprout:[0,1,2,5,3],license_1_0:3,all_of:[0,5],through:3,content:1,static_assert:[2,5],miscellan:4,copyright:[1,3],complex:[2,5],bind2nd:[2,5],typenam:[2,5],under:3,input:[2,5],modul:1,applic:[2,5],non:0,random:3,everi:5,greater:2,murakami:3,fals:[2,5],auto:[2,5],clang:3,number:3,facebook:3,recurs:[2,5],specif:4,list:4,synthes:[4,3],iter:[2,5,4],mode:3,contain:[2,5,4,3],page:[1,3],compil:[1,3],domain:4,twitter:3,see:3,result:[2,5],logn:[2,5],librari:[1,4,3],compat:4,index:1,slideshar:3,categori:4,version:3,net:3,boost:3,linear:[],onli:3,constexpr:3,base:3,preprocessor:4,path:3,modifi:0,invoc:[2,5],search:1,last:[2,5],com:3,licens:3,first:[2,5],oper:0,softwar:3,rang:[2,5],arrai:[2,5],genya:3,header:[2,5,3],linux:3,instal:[1,3],txt:3,inputiter:[2,5],blog:3,pred:[2,5],support:[1,4,3],empti:[2,5],websit:3,interfac:[2,5],includ:[2,5],bolero_murakami:3,conveni:[2,5],"function":[2,5,4],namespac:[2,5],copi:3,metaprogram:4,pars:[4,3],indic:1,mail:3,inlin:[2,5],"true":[2,5],than:[2,5],logarithm:[2,5],structur:4,exampl:[2,5],project:[1,3],sprout_constexpr:[2,5],can:3,www:3,otherwis:[2,5],genyamurakami:3,bolero:3,"int":[2,5],ani:2,templat:[2,5,4],rai:[4,3],hatena:3,file:3,tabl:1,"return":[2,5],gcc:3,end:[2,5],welcom:[1,3],lib:3,author:[1,3],hpp:[2,5],other:3,bool:[2,5],mathemat:4,document:1,begin:[2,5],http:3,distribut:3,trace:[4,3],sequenc:0,org:3,object:4,most:[2,5],data:4,github:3,algorithm:[0,2,5,4,3],directori:3,predic:[2,5],depth:[2,5],contact:3,thi:3,accompani:3,sprout_static_constexpr:[2,5]},titles:["Sprout.Algorithm","Welcome to Sprout’s documentation!","any_of","Sprout C++ Libraries","Libraries","all_of"],modules:{},descrefs:{},filenames:["libs/sprout/algorithm/index","index","libs/sprout/algorithm/any_of","libs/index","libs/libraries","libs/sprout/algorithm/all_of"]})
|
||||
Search.setIndex({desctypes:{},terms:{any_of:[0,2],all:7,less:7,sprout:[0,1,2,3,4,5,7],license_1_0:4,all_of:[0,7],through:4,content:1,onli:[5,4],miscellan:6,copyright:[1,4],bind2nd:[3,2,5,7],mathemat:6,under:4,mail:4,modul:1,applic:[3,2,5,7],non:0,random:4,"return":[3,2,5,7],greater:[3,2,5],murakami:4,fals:[3,2,5,7],auto:[3,2,5,7],clang:4,number:4,facebook:4,none_of:[0,3],recurs:[3,2,5,7],like:6,specif:6,list:6,synthes:[6,4],iter:[3,7,2,5,6],mode:4,contain:[3,2,4,5,6,7],path:4,page:[1,4],compil:[1,4],domain:6,twitter:4,see:4,result:[3,2,5,7],logn:[3,2,5,7],librari:[1,6,4],compat:6,index:1,slideshar:4,categori:6,version:4,net:4,boost:4,gener:6,static_assert:[3,2,5,7],constexpr:4,base:4,preprocessor:6,org:4,modifi:0,genyamurakami:4,search:1,last:[3,2,5,7],one_of:[0,5],com:4,licens:4,first:[3,2,5,7],oper:0,softwar:4,rang:[3,2,5,7],arrai:[3,2,5,7],genya:4,header:[3,2,5,7,4],linux:4,instal:[1,4],txt:4,inputiter:[3,2,5,7],blog:4,pred:[3,2,5,7],support:[1,6,4],empti:[3,2,5,7],websit:4,bolero_murakami:4,includ:[3,2,5,7],interfac:[3,2,5,7],conveni:[3,2,5,7],"function":[3,7,2,5,6],namespac:[3,2,5,7],copi:4,metaprogram:6,accompani:4,indic:1,input:[3,2,5,7],inlin:[3,2,5,7],"true":[3,2,5,7],than:[3,2,5,7],logarithm:[3,2,5,7],none:3,stl:6,structur:6,project:[1,4],sprout_constexpr:[3,2,5,7],can:4,www:4,otherwis:[3,2,5,7],invoc:[3,2,5,7],bolero:4,"int":[3,2,5,7],ani:2,templat:[3,7,2,5,6],rai:[6,4],hatena:4,file:4,tabl:1,everi:[3,7],gcc:4,end:[3,2,5,7],welcom:[1,4],lib:4,author:[1,4],hpp:[3,2,5,7],contact:4,other:4,complex:[3,2,5,7],bool:[3,2,5,7],document:1,begin:[3,2,5,7],http:4,distribut:4,trace:[6,4],sequenc:0,object:6,most:[3,2,5,7],typenam:[3,2,5,7],data:6,github:4,algorithm:[0,3,2,4,5,6,7],directori:4,predic:[3,2,5,7],depth:[3,2,5,7],exampl:[3,2,5,7],thi:4,pars:[6,4],sprout_static_constexpr:[3,2,5,7]},titles:["Sprout.Algorithm","Welcome to Sprout’s documentation!","any_of","none_of","Sprout C++ Libraries","one_of","Libraries","all_of"],modules:{},descrefs:{},filenames:["libs/sprout/algorithm/index","index","libs/sprout/algorithm/any_of","libs/sprout/algorithm/none_of","libs/index","libs/sprout/algorithm/one_of","libs/libraries","libs/sprout/algorithm/all_of"]})
|
|
@ -21,7 +21,7 @@ Containers and Data structures
|
|||
Algorithms
|
||||
=======================================
|
||||
|
||||
* :doc:`algorithm <./sprout/algorithm/index>`
|
||||
* :doc:`algorithm <./sprout/algorithm/index>` - STL-like generic algorithms.
|
||||
|
||||
.. _sprout-listed_by_category-algorithms:
|
||||
Algorithms
|
||||
|
|
|
@ -8,6 +8,8 @@ Sprout.Algorithm
|
|||
|
||||
all_of
|
||||
any_of
|
||||
none_of
|
||||
one_of
|
||||
|
||||
.. _sprout-algorithm-non_modifying:
|
||||
*******************************************************************************
|
||||
|
@ -18,3 +20,7 @@ Non-modifying sequence operations
|
|||
|
||||
* :doc:`./any_of`
|
||||
|
||||
* :doc:`./none_of`
|
||||
|
||||
* :doc:`./one_of`
|
||||
|
||||
|
|
46
source/libs/sprout/algorithm/none_of.rst
Normal file
46
source/libs/sprout/algorithm/none_of.rst
Normal file
|
@ -0,0 +1,46 @@
|
|||
.. _sprout-algorithm-none_of:
|
||||
###############################################################################
|
||||
none_of
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
none_of(InputIterator first, InputIterator last, Predicate pred);
|
||||
|
||||
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.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/algorithm/none_of.hpp>
|
||||
#include <sprout/array.hpp>
|
||||
#include <sprout/container.hpp>
|
||||
#include <sprout/functional.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::none_of(begin(input), end(input), bind2nd(greater<>(), 10));
|
||||
static_assert(result, "none of input is greater than 10.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
At most ``last - first`` applications of the predicate.
|
||||
|
||||
Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
``sprout/algorithm/none_of.hpp``
|
||||
|
||||
Convenience header: ``sprout/algorithm.hpp``
|
||||
|
46
source/libs/sprout/algorithm/one_of.rst
Normal file
46
source/libs/sprout/algorithm/one_of.rst
Normal file
|
@ -0,0 +1,46 @@
|
|||
.. _sprout-algorithm-one_of:
|
||||
###############################################################################
|
||||
one_of
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
one_of(InputIterator first, InputIterator last, Predicate pred);
|
||||
|
||||
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.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/algorithm/one_of.hpp>
|
||||
#include <sprout/array.hpp>
|
||||
#include <sprout/container.hpp>
|
||||
#include <sprout/functional.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::one_of(begin(input), end(input), bind2nd(greater<>(), 9));
|
||||
static_assert(result, "one of input is greater than 9.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
At most ``last - first`` applications of the predicate.
|
||||
|
||||
Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
``sprout/algorithm/one_of.hpp``
|
||||
|
||||
Convenience header: ``sprout/algorithm.hpp``
|
||||
|
Loading…
Add table
Reference in a new issue