Priority queue interface wrapper for heaps. More...
#include <ogdf/basic/PriorityQueue.h>
Public Types | |
using | const_reference = const value_type & |
using | handle = typename SpecImpl::Handle |
using | reference = value_type & |
using | size_type = std::size_t |
using | value_type = T |
Public Member Functions | |
PriorityQueue (const C &cmp=C(), int initialSize=128) | |
Creates empty priority queue. | |
PriorityQueue (const PriorityQueue &other) | |
Copy constructor. | |
template<class InputIt > | |
PriorityQueue (InputIt first, InputIt last, const C &cmp=C()) | |
Creates priority queue with contents of the given range. | |
PriorityQueue (PriorityQueue &&other) | |
Move constructor. | |
PriorityQueue (std::initializer_list< value_type > init, const C &cmp=C()) | |
Creates priority queue with contents of the given initializer list. | |
~PriorityQueue () | |
Destroys the underlying data structure. | |
void | clear () |
Removes all the entries from the queue. | |
void | decrease (handle pos, const T &value) |
Decreases value of the element specified by handle to value . | |
bool | empty () const |
Checks whether the queue is empty. | |
void | merge (PriorityQueue &other) |
Merges in enqueued values of other queue. | |
PriorityQueue & | operator= (PriorityQueue other) |
Copy and move assignment. | |
PriorityQueue & | operator= (std::initializer_list< value_type > ilist) |
Assigns the priority queue contents of the given initializer list. | |
void | pop () |
Removes the top element from the heap. | |
handle | push (const value_type &value) |
Inserts a new element with given value into the queue. | |
template<class InputIt > | |
void | push (InputIt first, InputIt last) |
Inserts new elements specified by the given range. | |
void | push (std::initializer_list< value_type > ilist) |
Inserts new elements specified by the given initializer list. | |
size_type | size () const |
Returns the number of enqueued elements. | |
void | swap (PriorityQueue &other) |
Swaps the contents. | |
const T & | top () const |
Returns reference to the top element in the queue. | |
const T & | value (handle pos) const |
Returns the priority of that handle. | |
Private Types | |
using | SpecImpl = Impl< T, C > |
Private Attributes | |
const C & | m_cmp |
SpecImpl * | m_impl |
Underlying heap data structure. | |
size_type | m_size |
Number of entries. | |
Friends | |
void | swap (PriorityQueue &a, PriorityQueue &b) |
Swaps the contents. | |
Priority queue interface wrapper for heaps.
Priority queue offers interface similar to the STL's std::priority_queue
class but allows to choose from variety of different data structures to be used as underlying implementation. Also, unlike STL's version it provides extra methods for fast decreasing key of given element and merging-in other priority queue.
T | Denotes value type of inserted elements. |
C | Denotes comparison functor determining value ordering. |
Impl | Denotes underlying heap class. |
Definition at line 60 of file PriorityQueue.h.
using ogdf::PriorityQueue< T, C, Impl >::const_reference = const value_type& |
Definition at line 74 of file PriorityQueue.h.
using ogdf::PriorityQueue< T, C, Impl >::handle = typename SpecImpl::Handle |
Definition at line 72 of file PriorityQueue.h.
using ogdf::PriorityQueue< T, C, Impl >::reference = value_type& |
Definition at line 73 of file PriorityQueue.h.
using ogdf::PriorityQueue< T, C, Impl >::size_type = std::size_t |
Definition at line 62 of file PriorityQueue.h.
|
private |
Definition at line 67 of file PriorityQueue.h.
using ogdf::PriorityQueue< T, C, Impl >::value_type = T |
Definition at line 71 of file PriorityQueue.h.
|
inlineexplicit |
Creates empty priority queue.
cmp | Comparison functor determining priority ordering. |
initialSize | The initial capacity preference (ignored if not supported by underlying heap). |
Definition at line 81 of file PriorityQueue.h.
|
inline |
Copy constructor.
Definition at line 85 of file PriorityQueue.h.
|
inline |
Move constructor.
Definition at line 89 of file PriorityQueue.h.
|
inline |
Creates priority queue with contents of the given range.
first | Begin iterator of the initializing range. |
last | Past-the-end iterator of the initializing range. |
cmp | Comparison functor determining priority ordering. |
Definition at line 100 of file PriorityQueue.h.
|
inline |
Creates priority queue with contents of the given initializer list.
init | List whose elements should be used during initalization. |
cmp | Comparison functor determining priority ordering. |
Definition at line 109 of file PriorityQueue.h.
|
inline |
Destroys the underlying data structure.
Definition at line 113 of file PriorityQueue.h.
|
inline |
Removes all the entries from the queue.
Definition at line 204 of file PriorityQueue.h.
|
inline |
Decreases value of the element specified by handle
to value
.
Behaviour of this function is undefined if handle does not belong to a the queue or new value is greater than old one.
pos | A element for which the value is to be decreased. |
value | A new value for the node. |
Definition at line 189 of file PriorityQueue.h.
|
inline |
Checks whether the queue is empty.
Definition at line 210 of file PriorityQueue.h.
|
inline |
Merges in enqueued values of other
queue.
After merge other
queue becomes empty and is valid for further usage.
other | A queue to be merged in. |
Definition at line 197 of file PriorityQueue.h.
|
inline |
Copy and move assignment.
Definition at line 116 of file PriorityQueue.h.
|
inline |
Assigns the priority queue contents of the given initializer list.
ilist | List whose elements should be assigned. |
Definition at line 126 of file PriorityQueue.h.
|
inline |
Removes the top element from the heap.
Behaviour of this function is undefined if the heap is empty.
Definition at line 176 of file PriorityQueue.h.
|
inline |
Inserts a new element with given value
into the queue.
Definition at line 149 of file PriorityQueue.h.
|
inline |
Inserts new elements specified by the given range.
first | Begin iterator of the range being inserted. |
last | Past-the-end iterator of the range being inserted. |
Definition at line 160 of file PriorityQueue.h.
|
inline |
Inserts new elements specified by the given initializer list.
ilist | List whose elements should be used during insertion. |
Definition at line 170 of file PriorityQueue.h.
|
inline |
Returns the number of enqueued elements.
Definition at line 213 of file PriorityQueue.h.
|
inline |
Swaps the contents.
Definition at line 133 of file PriorityQueue.h.
|
inline |
Returns reference to the top element in the queue.
Definition at line 142 of file PriorityQueue.h.
|
inline |
Returns the priority of that handle.
pos | The handle |
Definition at line 221 of file PriorityQueue.h.
|
friend |
Swaps the contents.
Definition at line 139 of file PriorityQueue.h.
|
private |
Definition at line 66 of file PriorityQueue.h.
|
private |
Underlying heap data structure.
Definition at line 68 of file PriorityQueue.h.
|
private |
Number of entries.
Definition at line 65 of file PriorityQueue.h.