42#include <gtest/gtest.h>
47using namespace testing;
54 std::vector<int>
tmp(v.size() + 1);
55 for (
size_t i = 0; i < v.size(); ++i)
65 std::vector<int>
heap_like{1, 3, 2, 7, 5, 4};
78 int arr[5] = {0, 1, 3, 2, 0};
93 int arr[6] = {0, 9, 1, 2, 3, 4};
105 int arr[8] = {0, 1, 3, 2, 7, 5, 4, 8};
123 std::vector<int> v{5, 1, 4, 2, 8, 0, 3, 7, 6, 9};
133 std::vector<int> v{12, -1, 5, 5, 3, 99, 0, -10, 7, 2, 4};
static bool is_min_heap(const std::vector< int > &v)
size_t size() const noexcept
Count the number of elements of the list.
iterator end() noexcept
Return an STL-compatible end iterator.
iterator begin() noexcept
Return an STL-compatible iterator to the first element.
int cmp(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
Main namespace for Aleph-w library functions.
void sift_down_up(T *ptr, const size_t l, const size_t i, const size_t r, Compare &cmp)
Restore the heap property by sifting down and then sifting up.
void sift_down(T *ptr, const size_t l, const size_t r, Compare &cmp)
Restore the heap property by moving the element at position l downwards.
void heapsort(T *array, const size_t n, const Compare &cmp=Compare())
Sort an array using the heapsort algorithm.
void faster_heapsort(T *array, const size_t n, const Compare &cmp=Compare())
Optimized version of heapsort.
bool valid_heap(T *array, const size_t l, const size_t r, const Compare &cmp=Compare())
Check whether a range satisfies the heap property.
T & sift_up(T *ptr, const size_t l, const size_t r, Compare &cmp)
Restore the heap property by moving the element at position r upwards.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Fixed-capacity binary heap and heapsort algorithms.