mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-16 15:14:13 +00:00
add source
This commit is contained in:
parent
75645c6220
commit
d3df37cbb1
7 changed files with 359 additions and 0 deletions
46
source/libs/sprout/algorithm/all_of.rst
Normal file
46
source/libs/sprout/algorithm/all_of.rst
Normal file
|
@ -0,0 +1,46 @@
|
|||
.. _sprout-algorithm-all_of:
|
||||
###############################################################################
|
||||
all_of
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
all_of(InputIterator first, InputIterator last, Predicate pred);
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
*true* if [first,last) is empty or if ``pred(*i)`` is true for every iterator i in the range [first,last), and *false* otherwise.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/algorithm/all_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::all_of(begin(input), end(input), bind2nd(less<>(), 11));
|
||||
static_assert(result, "all of input is less than 11.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
At most ``last - first`` applications of the predicate.
|
||||
|
||||
Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
``sprout/algorithm/all_of.hpp``
|
||||
|
||||
Convenience header: ``sprout/algorithm.hpp``
|
||||
|
46
source/libs/sprout/algorithm/any_of.rst
Normal file
46
source/libs/sprout/algorithm/any_of.rst
Normal file
|
@ -0,0 +1,46 @@
|
|||
.. _sprout-algorithm-any_of:
|
||||
###############################################################################
|
||||
any_of
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
any_of(InputIterator first, InputIterator last, Predicate pred);
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
*false* if [first,last) is empty or if there is no iterator i in the range [first,last) such that ``pred(*i)`` is true, and *true* otherwise.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/algorithm/any_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::any_of(begin(input), end(input), bind2nd(greater<>(), 5));
|
||||
static_assert(result, "any of input is greater than 5.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
At most ``last - first`` applications of the predicate.
|
||||
|
||||
Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
``sprout/algorithm/any_of.hpp``
|
||||
|
||||
Convenience header: ``sprout/algorithm.hpp``
|
||||
|
20
source/libs/sprout/algorithm/index.rst
Normal file
20
source/libs/sprout/algorithm/index.rst
Normal file
|
@ -0,0 +1,20 @@
|
|||
.. _sprout-algorithm:
|
||||
###############################################################################
|
||||
Sprout.Algorithm
|
||||
###############################################################################
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
|
||||
all_of
|
||||
any_of
|
||||
|
||||
.. _sprout-algorithm-non_modifying:
|
||||
*******************************************************************************
|
||||
Non-modifying sequence operations
|
||||
*******************************************************************************
|
||||
|
||||
* :doc:`./all_of`
|
||||
|
||||
* :doc:`./any_of`
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue