mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-12 14:54:10 +00:00
add doc: Heap operation
This commit is contained in:
parent
c4e3ce3d5e
commit
22cff01bf8
12 changed files with 536 additions and 4 deletions
|
@ -37,6 +37,8 @@ Sprout.Algorithm
|
|||
upper_bound
|
||||
equal_range
|
||||
binary_search
|
||||
is_heap
|
||||
is_heap_until
|
||||
|
||||
.. _sprout-algorithm-non_modifying:
|
||||
*******************************************************************************
|
||||
|
|
46
docs/_sources/libs/sprout/algorithm/is_heap.txt
Normal file
46
docs/_sources/libs/sprout/algorithm/is_heap.txt
Normal 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``
|
||||
|
48
docs/_sources/libs/sprout/algorithm/is_heap_until.txt
Normal file
48
docs/_sources/libs/sprout/algorithm/is_heap_until.txt
Normal 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``
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue