add doc:is_sorted, is_sorted_until

This commit is contained in:
Bolero-MURAKAMI 2013-08-22 01:56:46 +09:00
parent 2cfe358464
commit 15397fdd71
13 changed files with 537 additions and 5 deletions

View file

@ -27,6 +27,8 @@ Sprout.Algorithm
is_permutation
search
search_n
is_sorted
is_sorted_until
.. _sprout-algorithm-non_modifying:
*******************************************************************************

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

@ -13,7 +13,7 @@ Interface
template<typename InputIterator1, typename InputIterator2>
inline SPROUT_CONSTEXPR sprout::pair<InputIterator1, InputIterator2>
mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2;
mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
template<typename InputIterator1, typename InputIterator2>
inline SPROUT_CONSTEXPR sprout::pair<InputIterator1, InputIterator2>