44#include <gtest/gtest.h>
53 const std::vector<int> values = {7, 3, 11, 0, 5, 9, 1};
55 for (
const int v : values)
74 const std::vector<int> values = {40, 10, 30, 20, 50, 60, 70, 15};
75 std::vector<std::reference_wrapper<int>>
refs;
76 refs.reserve(values.size());
78 for (
const int v : values)
86 std::vector<int> remaining;
88 remaining.push_back(heap.
getMin());
127 std::vector<int> values(200);
128 std::iota(values.begin(), values.end(), -100);
129 std::mt19937
rng(42);
130 std::shuffle(values.begin(), values.end(),
rng);
147 constexpr size_t N = 64;
148 for (
size_t i = 0; i <
N; ++i)
149 heap.
insert(
static_cast<int>(i));
152 for (
auto it = heap.
get_it(); it.has_curr(); it.next())
161 for (
int i = 0; i < 50; ++i)
177 std::vector<std::reference_wrapper<int>>
refs;
178 for (
int i = 0; i < 5; ++i)
Dynamic heap of elements of type T ordered by a comparison functor.
T & top() const
Return a reference to the smallest element.
T getMin()
Remove the minimum element (according to Compare) and return it.
void update(T &data) noexcept
Adjust the position of an element after mutating its priority.
void empty() noexcept
Remove every element.
bool remove(T &data) noexcept
Remove an arbitrary element belonging to the heap.
T & insert(const T &item)
Insert a copy of item into the heap.
bool is_empty() const noexcept
const size_t & size() const noexcept
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
iterator end() noexcept
Return an STL-compatible end iterator.
iterator begin() noexcept
Return an STL-compatible iterator to the first element.
Main namespace for Aleph-w library functions.
static long & low(typename GT::Node *p)
Internal helper: low-link value stored directly in NODE_COOKIE(p).
DynList< T > maps(const C &c, Op op)
Classic map operation.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
Dynamic binary heap with node-based storage.