38#include <gtest/gtest.h>
50using namespace testing;
54 template <
typename Heap>
55 std::vector<typename Heap::Item_Type>
drain(Heap &
h)
57 std::vector<typename Heap::Item_Type>
out;
59 out.push_back(
h.getMin());
65 bool operator()(
int a,
int b)
const noexcept {
return a > b; }
148 for (
int i = 1; i <= 10; ++i)
155 bool operator()(
int x)
170 for (
int i = 1; i <= 10; ++i)
191 std::mt19937_64
rng(0xD15EA5EULL);
192 std::uniform_int_distribution<int>
op_dist(0, 99);
193 std::uniform_int_distribution<int>
val_dist(-10000, 10000);
196 std::priority_queue<int, std::vector<int>, std::greater<int>>
ref;
198 constexpr int ops = 30000;
199 for (
int i = 0; i <
ops; ++i)
Dynamic heap (priority queue) backed by DynArray.
void reserve(size_t n)
Ensure the underlying array has capacity for at least n elements.
constexpr bool is_empty() const noexcept
Return true if the heap is empty.
T getMin()
Remove and return the top element.
bool traverse(Operation &operation)
Traverse all elements in the heap.
T & put(const T &key)
Alias for insert().
T & append(const T &key)
Alias for insert().
T & insert(const T &key)
Insert a copy of key into the heap.
T & top()
Return the element with highest priority (the heap top).
T & insert_direct(const T &key)
Insert by directly indexing into the backing array.
constexpr size_t size() const noexcept
Return the number of elements.
void empty() noexcept
empty the list
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.
Main namespace for Aleph-w library functions.
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.
Array-based dynamic binary heap.