18 #ifndef INCLUDED_PRIORITYQUEUE
19 #define INCLUDED_PRIORITYQUEUE
27 #define PRIORITYQUEUE_DEBUG 0
29 #define PRIORITYQUEUE_DEBUG 1
32 template <
typename Item,
typename CMP>
37 if (
CMP()(b.rank, a.rank))
39 if (
CMP()(a.rank, b.rank))
47 #if PRIORITYQUEUE_DEBUG
60 template <
typename ID,
typename R,
typename CMP = std::less<R> >
70 void push(
const Item& item)
78 for (
size_t n = 0; n <
m_Heap.size(); ++n)
88 for (
size_t n = 0; n <
m_Heap.size(); ++n)
92 #if PRIORITYQUEUE_DEBUG
104 #if PRIORITYQUEUE_DEBUG
133 template <
typename ID,
typename R,
typename CMP = std::less<R> >
150 for (
size_t n = 0; n <
m_List.size(); ++n)
165 #if PRIORITYQUEUE_DEBUG
171 size_t bestidx =
m_List.size()-1;
199 #endif // INCLUDED_PRIORITYQUEUE
Priority queue implemented as a binary heap.
void push(const Item &item)
bool operator()(const Item &a, const Item &b)
std::vector< Item > m_Heap
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
void promote(ID id, R newrank)
void promote(ID id, R newrank)
std::vector< Item > m_List
Priority queue implemented as an unsorted array.
#define debug_warn(expr)
display the error dialog with the given text.
void push(const Item &item)