Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TArrayHeap.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <array>
5#include <functional>
6#include <concepts>
7
8namespace ph
9{
10
19template<typename T, std::size_t N, typename IsLess = std::less<T>>
20class TArrayHeap final
21{
22public:
25 TArrayHeap() requires std::default_initializable<IsLess>;
26
29 explicit TArrayHeap(IsLess isLess);
30
34 template<typename U>
35 void push(U&& item);
36
40 void pop();
41
47 T& top();
48 const T& top() const;
50
51 std::size_t size() const;
52 void clear();
53 bool isEmpty() const;
54
55private:
56 // Must be signed type
57 using Index = int;
58
59 std::array<T, N> m_data;
60 Index m_currentIndex;
61
62 [[no_unique_address]] IsLess m_isLess;
63};
64
65}// end namespace ph
66
A fixed size heap backed by an array. The container inherits the properties of a fixed size array of ...
Definition TArrayHeap.h:21
TArrayHeap()
Definition TArrayHeap.ipp:14
void pop()
Removes the top item from the heap. The item originally at the target index is still alive after this...
Definition TArrayHeap.ipp:36
bool isEmpty() const
Definition TArrayHeap.ipp:75
void clear()
Definition TArrayHeap.ipp:69
std::size_t size() const
Definition TArrayHeap.ipp:61
void push(U &&item)
Adds an item to the heap. The item originally at the target index will be overwritten.
Definition TArrayHeap.ipp:27
T & top()
Access the top item of the heap. By default, the top item is the maximum item (max heap)....
Definition TArrayHeap.ipp:45
The root for all renderer implementations.
Definition EEngineProject.h:6