fix directory structure

This commit is contained in:
Bolero-MURAKAMI 2013-08-30 14:02:02 +09:00
parent bd73a0c510
commit bf12021ae6
241 changed files with 1777 additions and 2122 deletions

View 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's return value.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/adjacent_find.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,44 @@
.. _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``

View file

@ -0,0 +1,43 @@
.. _sprout-algorithm-all_of_equal:
###############################################################################
all_of_equal
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename InputIterator, typename T>
inline SPROUT_CONSTEXPR bool
all_of_equal(InputIterator first, InputIterator last, T const& value);
Returns
========================================
| true if [first,last) is empty or if ``*i == value`` is true for every iterator i in the range [first,last), and false otherwise.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/all_of_equal.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::all_of_equal(begin(input), end(input), 1);
static_assert(result, "all of input is equal to 1.");
Complexity
========================================
| At most ``last - first`` applications of the predicate.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/all_of_equal.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,44 @@
.. _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``

View file

@ -0,0 +1,43 @@
.. _sprout-algorithm-any_of_equal:
###############################################################################
any_of_equal
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename InputIterator, typename T>
inline SPROUT_CONSTEXPR bool
any_of_equal(InputIterator first, InputIterator last, T const& value);
Returns
========================================
| false if [first,last) is empty or if there is no iterator i in the range [first,last) such that ``*i == value`` is true, and true otherwise.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/any_of_equal.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::any_of_equal(begin(input), end(input), 1);
static_assert(result, "any of input is equal to 1.");
Complexity
========================================
| At most ``last - first`` applications of the predicate.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/any_of_equal.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,53 @@
.. _sprout-algorithm-binary_search:
###############################################################################
binary_search
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator, typename T>
inline SPROUT_CONSTEXPR bool
binary_search(ForwardIterator first, ForwardIterator last, T const& value);
template<typename ForwardIterator, typename T, typename Compare>
inline SPROUT_CONSTEXPR bool
binary_search(ForwardIterator first, ForwardIterator last, T const& value, Compare comp);
Requires
========================================
| The elements e of [first,last) are partitioned with respect to the expressions ``e < value`` and ``!(value < e)`` or ``comp(e, value)`` and ``!comp(value, e)``.
| Also, for all elements e of [first,last), ``e < value`` implies ``!(value < e)`` or ``comp(e, value)`` implies ``!comp(value, e)``.
Returns
========================================
| true if there is an iterator i in the range [first,last) that satisfies the corresponding conditions: ``!(*i < value) && !(value < *i)`` or ``comp(*i, value) && comp(value, *i)``.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/binary_search.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, 5, 5, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::binary_search(begin(input), end(input), 5);
static_assert(result, "found 5 by binary search.");
Complexity
========================================
| At most ``log2(last - first) + O(1)`` comparisons.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/binary_search.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

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

View file

@ -0,0 +1,43 @@
.. _sprout-algorithm-count:
###############################################################################
count
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename InputIterator, typename T>
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
count(InputIterator first, InputIterator last, T const& value);
Returns
========================================
| The number of iterators i in the range [first,last) for which the following corresponding conditions hold: ``*i == value``.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/count.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, 5, 5, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::count(begin(input), end(input), 5);
static_assert(result == 4, "counted 4 elements equal to 5 from input.");
Complexity
========================================
| Exactly ``last - first`` applications of the predicate.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/count.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,44 @@
.. _sprout-algorithm-count_if:
###############################################################################
count_if
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename InputIterator, typename Predicate>
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
count_if(InputIterator first, InputIterator last, Predicate pred);
Returns
========================================
| The number of iterators i in the range [first,last) for which the following corresponding conditions hold: ``pred(*i)``.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/count_if.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::count_if(begin(input), end(input), bind2nd(modulus<>(), 2));
static_assert(result == 5, "counted 5 elements of odd number from input.");
Complexity
========================================
| Exactly ``last - first`` applications of the predicate.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/count_if.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,64 @@
.. _sprout-algorithm-equal:
###############################################################################
equal
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename InputIterator1, typename InputIterator2, typename BinaryPredicate>
inline SPROUT_CONSTEXPR bool
equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred);
template<typename InputIterator1, typename InputIterator2>
inline SPROUT_CONSTEXPR bool
equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
template<typename InputIterator1, typename InputIterator2, typename BinaryPredicate>
inline SPROUT_CONSTEXPR bool
equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred);
template<typename InputIterator1, typename InputIterator2>
inline SPROUT_CONSTEXPR bool
equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
Remarks
========================================
| If last2 was not given in the argument list, it denotes ``first2 + (last1 - first1)`` below.
Returns
========================================
| If ``last1 - first1 != last2 - first2``, return false.
| Otherwise return true if for every iterator i in the range [first1,last1) the following corresponding conditions hold: ``*i == *(first2 + (i - first1))``, ``pred(*i, *(first2 + (i - first1)))``.
| Otherwise, returns false.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/equal.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input1 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto input2 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(begin(input1), end(input1), begin(input2), end(input2));
static_assert(result, "input2 equals to input1.");
Complexity
========================================
| No applications of the corresponding predicate if InputIterator1 and InputIterator2 meet the requirements of random access iterators and ``last1 - first1 != last2 - first2``.
| Otherwise, at most ``min(last1 - first1, last2 - first2)`` applications of the corresponding predicate.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/equal.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,58 @@
.. _sprout-algorithm-equal_range:
###############################################################################
equal_range
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator, typename T>
inline SPROUT_CONSTEXPR sprout::pair<ForwardIterator, ForwardIterator>
equal_range(ForwardIterator first, ForwardIterator last, T const& value);
template<typename ForwardIterator, typename T, typename Compare>
inline SPROUT_CONSTEXPR sprout::pair<ForwardIterator, ForwardIterator>
equal_range(ForwardIterator first, ForwardIterator last, T const& value, Compare comp);
Requires
========================================
| The elements e of [first,last) shall be partitioned with respect to the expressions ``e < value`` and ``!(value < e)`` or ``comp(e, value)`` and ``!comp(value, e)``.
| Also, for all elements e of [first, last), ``e < value`` shall imply ``!(value < e)`` or ``comp(e, value)`` shall imply ``!comp(value, e)``.
Returns
========================================
| ``make_pair(lower_bound(first, last, value), upper_bound(first, last, value))``
| or
| ``make_pair(lower_bound(first, last, value, comp), upper_bound(first, last, value, comp))``
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/equal_range.hpp>
#include <sprout/algorithm/all_of_equal.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, 5, 5, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal_range(begin(input), end(input), 5);
static_assert(result.first - begin(input) == 3, "a lower bound position is 3.");
static_assert(result.second - begin(input) == 7, "a upper bound position is 7.");
static_assert(sprout::all_of_equal(result.first, result.second. 5), "all of result range is equal to 5.");
Complexity
========================================
| At most ``2 * log2(last - first) + O(1)`` comparisons.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/equal_range.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,45 @@
.. _sprout-algorithm-find:
###############################################################################
find
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename InputIterator, typename T>
inline SPROUT_CONSTEXPR InputIterator
find(InputIterator first, InputIterator last, T const& value);
Returns
========================================
| The first iterator i in the range [first,last) for which the following corresponding conditions hold: ``*i == value``.
| Returns last if no such iterator is found.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/find.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::find(begin(input), end(input), 8);
static_assert(result != end(input), "found a element equal to 8 from input.");
static_assert(result - begin(input1) == 7, "a found position is 7.");
Complexity
========================================
| At most ``last - first`` applications of the predicate.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/find.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View 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``

View 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 ``(last1 - first1) * (last2 - first2)`` 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``

View file

@ -0,0 +1,46 @@
.. _sprout-algorithm-find_if:
###############################################################################
find_if
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename InputIterator, typename Predicate>
inline SPROUT_CONSTEXPR InputIterator
find_if(InputIterator first, InputIterator last, Predicate pred);
Returns
========================================
| The first iterator i in the range [first,last) for which the following corresponding conditions hold: ``pred(*i)``.
| Returns last if no such iterator is found.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/find_if.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::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 - begin(input1) == 7, "a found position is 7.");
Complexity
========================================
| At most ``last - first`` applications of the predicate.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/find_if.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,46 @@
.. _sprout-algorithm-find_if_not:
###############################################################################
find_if_not
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename InputIterator, typename Predicate>
inline SPROUT_CONSTEXPR InputIterator
find_if_not(InputIterator first, InputIterator last, Predicate pred);
Returns
========================================
| The first iterator i in the range [first,last) for which the following corresponding conditions hold: ``!pred(*i)``.
| Returns last if no such iterator is found.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/find_if_not.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::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 - begin(input1) == 7, "a found position is 7.");
Complexity
========================================
| At most ``last - first`` applications of the predicate.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/find_if_not.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,162 @@
.. _sprout-algorithm:
###############################################################################
Sprout.Algorithm
###############################################################################
.. toctree::
:hidden:
all_of
all_of_equal
any_of
any_of_equal
none_of
none_of_equal
one_of
one_of_equal
find
find_if
find_if_not
find_end
find_first_of
adjacent_find
count
count_if
mismatch
equal
is_permutation
search
search_n
is_sorted
is_sorted_until
is_increasing
is_decreasing
is_strictly_increasing
is_strictly_decreasing
lower_bound
upper_bound
equal_range
binary_search
is_heap
is_heap_until
min
max
minmax
min_element
max_element
minmax_element
lexicographical_compare
tristate_lexicographical_compare
clamp
.. _sprout-algorithm-non_modifying:
*******************************************************************************
Non-modifying sequence operations
*******************************************************************************
======================================== ===============================================================================
function
======================================== ===============================================================================
:doc:`all_of <./all_of>`
:doc:`all_of_equal <./all_of_equal>`
:doc:`any_of <./any_of>`
:doc:`any_of_equal <./any_of_equal>`
:doc:`none_of <./none_of>`
:doc:`none_of_equal <./none_of_equal>`
:doc:`one_of <./one_of>`
:doc:`one_of_equal <./one_of_equal>`
:doc:`find <./find>`
:doc:`find_if <./find_if>`
:doc:`find_if_not <./find_if_not>`
:doc:`find_end <./find_end>`
:doc:`find_first_of <./find_first_of>`
:doc:`adjacent_find <./adjacent_find>`
:doc:`count <./count>`
:doc:`count_if <./count_if>`
:doc:`mismatch <./mismatch>`
:doc:`equal <./equal>`
:doc:`is_permutation <./is_permutation>`
:doc:`search <./search>`
:doc:`search_n <./search_n>`
======================================== ===============================================================================
.. _sprout-algorithm-non_modifying-sorting:
Sorting
========================================
================================================================================ ===============================================================================
function
================================================================================ ===============================================================================
:doc:`is_sorted <./is_sorted>`
:doc:`is_sorted_until <./is_sorted_until>`
:doc:`is_increasing <./is_increasing>`
:doc:`is_decreasing <./is_decreasing>`
:doc:`is_strictly_increasing <./is_strictly_increasing>`
:doc:`is_strictly_decreasing <./is_strictly_decreasing>`
================================================================================ ===============================================================================
.. _sprout-algorithm-non_modifying-binary:
Binary search
========================================
======================================== ===============================================================================
function
======================================== ===============================================================================
:doc:`lower_bound <./lower_bound>`
:doc:`upper_bound <./upper_bound>`
:doc:`equal_range <./equal_range>`
:doc:`binary_search <./binary_search>`
======================================== ===============================================================================
.. _sprout-algorithm-non_modifying-heap:
Heap operations
========================================
======================================== ===============================================================================
function
======================================== ===============================================================================
:doc:`is_heap <./is_heap>`
:doc:`is_heap_until <./is_heap_until>`
======================================== ===============================================================================
.. _sprout-algorithm-non_modifying-minmax:
Minimum and maximum
========================================
======================================== ===============================================================================
function
======================================== ===============================================================================
:doc:`min <./min>`
:doc:`max <./max>`
:doc:`minmax <./minmax>`
:doc:`min_element <./min_element>`
:doc:`max_element <./max_element>`
:doc:`minmax_element <./minmax_element>`
======================================== ===============================================================================
.. _sprout-algorithm-non_modifying-lexicographical:
Lexicographical comparison
========================================
================================================================================ ===============================================================================
function
================================================================================ ===============================================================================
:doc:`lexicographical_compare <./lexicographical_compare>`
:doc:`tristate_lexicographical_compare <./tristate_lexicographical_compare>`
================================================================================ ===============================================================================
.. _sprout-algorithm-non_modifying-clamp:
Clamp algorithm
========================================
======================================== ===============================================================================
function
======================================== ===============================================================================
:doc:`clamp <./clamp>`
======================================== ===============================================================================
Header
========================================
``sprout/algorithm.hpp``

View file

@ -0,0 +1,42 @@
.. _sprout-algorithm-is_decreasing:
###############################################################################
is_decreasing
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator>
inline SPROUT_CONSTEXPR bool
is_decreasing(ForwardIterator first, ForwardIterator last);
Returns
========================================
| Same as ``is_sorted(first, last, greater<>())``.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/is_decreasing.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{5, 5, 4, 4, 3, 3, 2, 2, 1, 1}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_decreasing(begin(input), end(input));
static_assert(result, "input is decreasing.");
Complexity
========================================
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/is_decreasing.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,46 @@
.. _sprout-algorithm-is_heap:
###############################################################################
is_heap
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename RandomAccessIterator>
inline SPROUT_CONSTEXPR bool
is_heap(RandomAccessIterator first, RandomAccessIterator last);
template<typename RandomAccessIterator, typename Compare>
inline SPROUT_CONSTEXPR bool
is_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
Returns
========================================
| ``is_heap_until(first, last) == last``, ``is_heap_until(first, last, comp) == last``
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/is_heap.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{10, 9, 8, 6, 7, 2, 5, 3, 4, 1}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_heap(begin(input), end(input));
static_assert(result, "input is a heap.");
Complexity
========================================
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/is_heap.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,48 @@
.. _sprout-algorithm-is_heap_until:
###############################################################################
is_heap_until
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename RandomAccessIterator>
inline SPROUT_CONSTEXPR RandomAccessIterator
is_heap_until(RandomAccessIterator first, RandomAccessIterator last);
template<typename RandomAccessIterator, typename Compare>
inline SPROUT_CONSTEXPR RandomAccessIterator
is_heap_until(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
Returns
========================================
| If ``distance(first, last) < 2``, returns last.
| Otherwise, returns the last iterator i in [first,last] for which the range [first,i) is a heap.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/is_heap_until.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{10, 9, 8, 6, 7, 2, 5, 13, 14, 11}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_heap_until(begin(input), end(input));
static_assert(result - begin(input) == 7, "input is a heap until position 7.");
Complexity
========================================
| Linear.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/is_heap_until.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,42 @@
.. _sprout-algorithm-is_increasing:
###############################################################################
is_increasing
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator>
inline SPROUT_CONSTEXPR bool
is_increasing(ForwardIterator first, ForwardIterator last);
Returns
========================================
| Same as ``is_sorted(first, last, less<>())``.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/is_increasing.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 1, 2, 2, 3, 3, 4, 4, 5, 5}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_increasing(begin(input), end(input));
static_assert(result, "input is increasing.");
Complexity
========================================
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/is_increasing.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,63 @@
.. _sprout-algorithm-is_permutation:
###############################################################################
is_permutation
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
inline SPROUT_CONSTEXPR bool
is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, BinaryPredicate pred);
template<typename ForwardIterator1, typename ForwardIterator2>
inline SPROUT_CONSTEXPR bool
is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
inline SPROUT_CONSTEXPR bool
is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
template<typename ForwardIterator1, typename ForwardIterator2>
inline SPROUT_CONSTEXPR bool
is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2) {
Remarks
========================================
| If last2 was not given in the argument list, it denotes ``first2 + (last1 - first1)`` below.
Returns
========================================
| If ``last1 - first1 != last2 - first2``, return false.
| Otherwise return true if there exists a permutation of the elements in the range [first2,first2 + (last1 - first1)), beginning with ForwardIterator2 begin, such that ``equal(first1, last1, begin)`` returns true or ``equal(first1, last1, begin, pred)`` returns true; otherwise, returns false.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/is_permutation.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input1 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto input2 = array<int, 10>{{10, 9, 8, 1, 2, 3, 4, 5, 6, 7}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(begin(input1), end(input1), begin(input2), end(input2));
static_assert(result, "input2 is a permutation of input1.");
Complexity
========================================
| No applications of the corresponding predicate if ForwardIterator1 and ForwardIterator2 meet the requirements of random access iterators and ``last1 - first1 != last2 - first2``.
| Otherwise, exactly distance(first1, last1) applications of the corresponding predicate if ``equal(first1, last1, first2, last2)`` would return true if pred was not given in the argument list or ``equal(first1, last1, first2, last2, pred)`` would return true if pred was given in the argument list; otherwise, at worst O(N^2), where N has the value ``distance(first1, last1)``.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/is_permutation.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,46 @@
.. _sprout-algorithm-is_sorted:
###############################################################################
is_sorted
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator>
inline SPROUT_CONSTEXPR bool
is_sorted(ForwardIterator first, ForwardIterator last);
template<typename ForwardIterator, typename Compare>
inline SPROUT_CONSTEXPR bool
is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
Returns
========================================
| ``is_sorted_until(first, last) == last``, ``is_sorted_until(first, last, comp) == last``
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/is_sorted.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_sorted(begin(input), end(input));
static_assert(result, "input is sorted.");
Complexity
========================================
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/is_sorted.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,48 @@
.. _sprout-algorithm-is_sorted_until:
###############################################################################
is_sorted_until
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator>
inline SPROUT_CONSTEXPR ForwardIterator
is_sorted_until(ForwardIterator first, ForwardIterator last);
template<typename ForwardIterator, typename Compare>
inline SPROUT_CONSTEXPR ForwardIterator
is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
Returns
========================================
| If ``distance(first, last) < 2``, returns last.
| Otherwise, returns the last iterator i in [first,last] for which the range [first,i) is sorted.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/is_sorted_until.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{6, 7, 8, 8, 10, 1, 2, 3, 4, 5}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_sorted_until(begin(input), end(input));
static_assert(result - begin(input) == 5, "input is sorted until position 5.");
Complexity
========================================
| Linear.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/is_sorted_until.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,42 @@
.. _sprout-algorithm-is_strictly_decreasing:
###############################################################################
is_strictly_decreasing
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator>
inline SPROUT_CONSTEXPR bool
is_strictly_decreasing(ForwardIterator first, ForwardIterator last);
Returns
========================================
| Same as ``is_sorted(first, last, greater_equal<>())``.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/is_strictly_decreasing.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{10, 9, 8, 7, 6, 5, 4, 3, 2, 1}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_strictly_decreasing(begin(input), end(input));
static_assert(result, "input is strictly decreasing.");
Complexity
========================================
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/is_strictly_decreasing.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,42 @@
.. _sprout-algorithm-is_strictly_increasing:
###############################################################################
is_strictly_increasing
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator>
inline SPROUT_CONSTEXPR bool
is_strictly_increasing(ForwardIterator first, ForwardIterator last);
Returns
========================================
| Same as ``is_sorted(first, last, less_equal<>())``.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/is_strictly_increasing.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_strictly_increasing(begin(input), end(input));
static_assert(result, "input is strictly increasing.");
Complexity
========================================
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/is_strictly_increasing.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

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

View file

@ -0,0 +1,52 @@
.. _sprout-algorithm-lower_bound:
###############################################################################
lower_bound
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator, typename T>
inline SPROUT_CONSTEXPR ForwardIterator
lower_bound(ForwardIterator first, ForwardIterator last, T const& value);
template<typename ForwardIterator, typename T, typename Compare>
inline SPROUT_CONSTEXPR ForwardIterator
lower_bound(ForwardIterator first, ForwardIterator last, T const& value, Compare comp);
Requires
========================================
| The elements e of [first,last) shall be partitioned with respect to the expression ``e < value`` or ``comp(e, value)``.
Returns
========================================
| The furthermost iterator i in the range [first,last] such that for any iterator j in the range [first,i) the following corresponding conditions hold: ``*j < value`` or ``comp(*j, value)``.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/lower_bound.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, 5, 5, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::lower_bound(begin(input), end(input), 5);
static_assert(result - begin(input) == 3, "a lower bound position is 3.");
Complexity
========================================
| At most ``log2(last - first) + O(1)`` comparisons.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/lower_bound.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,85 @@
.. _sprout-algorithm-max:
###############################################################################
max
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename T>
inline SPROUT_CONSTEXPR T const&
max(T const& a, T const& b);
template<typename T, typename Compare>
inline SPROUT_CONSTEXPR T const&
max(T const& a, T const& b, Compare comp);
Requires
========================================
| Type T is LessThanComparable.
Returns
========================================
| The larger value.
Remarks
========================================
| Returns the first argument when the arguments are equivalent.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/max.hpp>
#include <sprout/array.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{-1, 1}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::max(input[0], input[1]);
static_assert(result == 1, "max value is 1.");
-------------------------------------------------------------------------------
Interface
========================================
.. sourcecode:: c++
template<typename T, typename Compare>
inline SPROUT_CONSTEXPR T
max(std::initializer_list<T> t, Compare comp);
template<typename T>
inline SPROUT_CONSTEXPR T
max(std::initializer_list<T> t);
Requires
========================================
| T is LessThanComparable and CopyConstructible and ``t.size() > 0``.
Returns
========================================
| The largest value in the initializer_list.
Remarks
========================================
| Returns a copy of the leftmost argument when several arguments are equivalent to the largest.
| If an implementation not support C++14 initializer_list (``SPROUT_NO_CXX14_INITIALIZER_LIST`` defined), then this function is not specified constexpr.
Complexity
========================================
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/max.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

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

View file

@ -0,0 +1,85 @@
.. _sprout-algorithm-min:
###############################################################################
min
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename T>
inline SPROUT_CONSTEXPR T const&
min(T const& a, T const& b);
template<typename T, typename Compare>
inline SPROUT_CONSTEXPR T const&
min(T const& a, T const& b, Compare comp);
Requires
========================================
| Type T is LessThanComparable.
Returns
========================================
| The smaller value.
Remarks
========================================
| Returns the first argument when the arguments are equivalent.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/min.hpp>
#include <sprout/array.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{-1, 1}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::min(input[0], input[1]);
static_assert(result == -1, "min value is -1.");
-------------------------------------------------------------------------------
Interface
========================================
.. sourcecode:: c++
template<typename T, typename Compare>
inline SPROUT_CONSTEXPR T
min(std::initializer_list<T> t, Compare comp);
template<typename T>
inline SPROUT_CONSTEXPR T
min(std::initializer_list<T> t);
Requires
========================================
| T is LessThanComparable and CopyConstructible and ``t.size() > 0``.
Returns
========================================
| The smallest value in the initializer_list.
Remarks
========================================
| Returns a copy of the leftmost argument when several arguments are equivalent to the smallest.
| If an implementation not support C++14 initializer_list (``SPROUT_NO_CXX14_INITIALIZER_LIST`` defined), then this function is not specified constexpr.
Complexity
========================================
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/min.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

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

View file

@ -0,0 +1,96 @@
.. _sprout-algorithm-minmax:
###############################################################################
minmax
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename T>
inline SPROUT_CONSTEXPR sprout::pair<T const&, T const&>
minmax(T const& a, T const& b);
template<typename T, typename Compare>
inline SPROUT_CONSTEXPR sprout::pair<T const&, T const&>
minmax(T const& a, T const& b, Compare comp);
Requires
========================================
| Type T shall be LessThanComparable.
Returns
========================================
| ``pair<T const&, T const&>(b, a)`` if b is smaller than a, and ``pair<T const&, T const&>(a, b)`` otherwise.
Remarks
========================================
| Returns ``pair<T const&, T const&>(a, b)`` when the arguments are equivalent.
Remarks
========================================
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/minmax.hpp>
#include <sprout/array.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{-1, 1}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::minmax(input[0], input[1]);
static_assert(result.first == -1, "min value is -1.");
static_assert(result.second == 1, "max value is 1.");
Complexity
========================================
| Exactly one comparison.
-------------------------------------------------------------------------------
Interface
========================================
.. sourcecode:: c++
template<typename T, typename Compare>
inline SPROUT_CONSTEXPR sprout::pair<T, T>
minmax(std::initializer_list<T> t, Compare comp);
template<typename T>
inline SPROUT_CONSTEXPR sprout::pair<T, T>
minmax(std::initializer_list<T> t);
Requires
========================================
| T is LessThanComparable and CopyConstructible and ``t.size() > 0``.
Returns
========================================
| ``pair<T, T>(x, y)``, where x has the smallest and y has the largest value in the initializer list.
Remarks
========================================
| x is a copy of the leftmost argument when several arguments are equivalent to the smallest.
| y is a copy of the rightmost argument when several arguments are equivalent to the largest.
| If an implementation not support C++14 initializer_list (``SPROUT_NO_CXX14_INITIALIZER_LIST`` defined), then this function is not specified constexpr.
Complexity
========================================
| At most ``(3/2) * t.size()`` applications of the corresponding predicate.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/minmax.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

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

View file

@ -0,0 +1,66 @@
.. _sprout-algorithm-mismatch:
###############################################################################
mismatch
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename InputIterator1, typename InputIterator2, typename BinaryPredicate>
inline SPROUT_CONSTEXPR sprout::pair<InputIterator1, InputIterator2>
mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred);
template<typename InputIterator1, typename InputIterator2>
inline SPROUT_CONSTEXPR sprout::pair<InputIterator1, InputIterator2>
mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
template<typename InputIterator1, typename InputIterator2>
inline SPROUT_CONSTEXPR sprout::pair<InputIterator1, InputIterator2>
mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
template<typename InputIterator1, typename InputIterator2, typename BinaryPredicate>
inline SPROUT_CONSTEXPR sprout::pair<InputIterator1, InputIterator2>
mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred);
Remarks
========================================
| If last2 was not given in the argument list, it denotes ``first2 + (last1 - first1)`` below.
Returns
========================================
| A pair of iterators i and j such that ``j == first2 + (i - first1)`` and i is the first iterator in the range [first1,last1) for which the following corresponding conditions hold:
* j is in the range [first2,last2).
* ``!(*i == *(first2 + (i - first1)))``
* ``!pred(*i, *(first2 + (i - first1)))``
| Returns the pair ``first1 + min(last1 - first1, last2 - first2)`` and ``first2 + min(last1 - first1, last2 - first2)`` if such an iterator i is not found.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/mismatch.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input1 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto input2 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 10, 9, 8}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::mismatch(begin(input1), end(input1), begin(input2), end(input2));
static_assert(result.first != end(input1) && result.second != end(input2), "input2 mismatches with input1.");
static_assert(result.first - begin(input1) == 7, "a mismatched position is 7.");
Complexity
========================================
| At most ``last1 - first1`` applications of the corresponding predicate.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/mismatch.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,44 @@
.. _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``

View file

@ -0,0 +1,43 @@
.. _sprout-algorithm-none_of_equal:
###############################################################################
none_of_equal
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename InputIterator, typename T>
inline SPROUT_CONSTEXPR bool
none_of_equal(InputIterator first, InputIterator last, T const& value);
Returns
========================================
| true if [first,last) is empty or if ``*i == value`` is false for every iterator i in the range [first,last), and false otherwise.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/none_of_equal.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::none_of_equal(begin(input), end(input), 11);
static_assert(result, "none of input is equal to 11.");
Complexity
========================================
| At most ``last - first`` applications of the predicate.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/none_of_equal.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,44 @@
.. _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``

View file

@ -0,0 +1,43 @@
.. _sprout-algorithm-one_of_equal:
###############################################################################
one_of_equal
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename InputIterator, typename T>
inline SPROUT_CONSTEXPR bool
one_of_equal(InputIterator first, InputIterator last, T const& value);
Returns
========================================
| true if [first,last) is not empty and there is only one iterator i in the range [first,last) such that ``*i == value`` is true, and false otherwise.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/one_of_equal.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::one_of_equal(begin(input), end(input), 1);
static_assert(result, "one of input is equal to 1.");
Complexity
========================================
| At most ``last - first`` applications of the predicate.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/one_of_equal.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,62 @@
.. _sprout-algorithm-search:
###############################################################################
search
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator1, typename ForwardIterator2>
inline SPROUT_CONSTEXPR ForwardIterator1
search(
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2
);
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
inline SPROUT_CONSTEXPR ForwardIterator1
search(
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred
);
Effects
========================================
| Finds a subsequence of equal values in a sequence.
Returns
========================================
| The first iterator i in the range [first1,last1 - (last2-first2)) such that for any nonnegative integer n less than ``last2 - first2`` the following corresponding conditions hold: ``*(i + n) == *(first2 + n)``, ``pred(*(i + n), *(first2 + n))``.
| Returns first1 if [first2,last2) is empty, otherwise returns last1 if no such iterator is found.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/search.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::search(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) == 2, "a found position is 2.");
Complexity
========================================
| At most ``(last1 - first1) * (last2 - first2)`` applications of the corresponding predicate.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/search.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

@ -0,0 +1,59 @@
.. _sprout-algorithm-search_n:
###############################################################################
search_n
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator, typename Size, typename T>
inline SPROUT_CONSTEXPR ForwardIterator
search_n(ForwardIterator first, ForwardIterator last, Size count, T const& value);
template<typename ForwardIterator, typename Size, typename T, typename BinaryPredicate>
inline SPROUT_CONSTEXPR ForwardIterator
search_n(ForwardIterator first, ForwardIterator last, Size count, T const& value, BinaryPredicate pred);
Requires
========================================
| The type Size shall be convertible to integral type.
Effects
========================================
| Finds a subsequence of equal values in a sequence.
Returns
========================================
| The first iterator i in the range [first,last-count) such that for any non-negative integer n less than count the following corresponding conditions hold: ``*(i + n) == value``, ``pred(*(i + n),value)``.
| Returns last if no such iterator is found.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/search_n.hpp>
#include <sprout/array.hpp>
#include <sprout/container.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input1 = array<int, 10>{{1, 2, 3, 5, 5, 5, 5, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::search_n(begin(input1), end(input1), 4, 5);
static_assert(result != end(input1), "found a subsequence equal to 4 values of 5 from input1.");
static_assert(result - begin(input1) == 3, "a found position is 3.");
Complexity
========================================
| At most ``last - first`` applications of the corresponding predicate.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/search_n.hpp``
| Convenience header: ``sprout/algorithm.hpp``

View file

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

View file

@ -0,0 +1,52 @@
.. _sprout-algorithm-upper_bound:
###############################################################################
upper_bound
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ForwardIterator, typename T>
inline SPROUT_CONSTEXPR ForwardIterator
upper_bound(ForwardIterator first, ForwardIterator last, T const& value);
template<typename ForwardIterator, typename T, typename Compare>
inline SPROUT_CONSTEXPR ForwardIterator
upper_bound(ForwardIterator first, ForwardIterator last, T const& value, Compare comp);
Requires
========================================
| The elements e of [first,last) shall be partitioned with respect to the expression ``!(value < e)`` or ``!comp(value, e)``.
Returns
========================================
| The furthermost iterator i in the range [first,last] such that for any iterator j in the range [first,i) the following corresponding conditions hold: ``!(value < *j)`` or ``!comp(value, *j)``.
Examples
========================================
.. sourcecode:: c++
#include <sprout/algorithm/upper_bound.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, 5, 5, 8, 9, 10}};
SPROUT_STATIC_CONSTEXPR auto result = sprout::upper_bound(begin(input), end(input), 5);
static_assert(result - begin(input) == 7, "a upper bound position is 7.");
Complexity
========================================
| At most ``log2(last - first) + O(1)`` comparisons.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/algorithm/upper_bound.hpp``
| Convenience header: ``sprout/algorithm.hpp``