Priority queue interface wrapper for heaps. More...
#include <ogdf/basic/PriorityQueue.h>
Inheritance diagram for ogdf::PriorityQueue< T, C, Impl >: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. More... | |
| PriorityQueue (const PriorityQueue &other) | |
| Copy constructor. More... | |
| PriorityQueue (PriorityQueue &&other) | |
| Move constructor. More... | |
| template<class InputIt > | |
| PriorityQueue (InputIt first, InputIt last, const C &cmp=C()) | |
| Creates priority queue with contents of the given range. More... | |
| PriorityQueue (std::initializer_list< value_type > init, const C &cmp=C()) | |
| Creates priority queue with contents of the given initializer list. More... | |
| ~PriorityQueue () | |
| Destroys the underlying data structure. More... | |
| void | clear () |
| Removes all the entries from the queue. More... | |
| void | decrease (handle pos, const T &value) |
Decreases value of the element specified by handle to value. More... | |
| bool | empty () const |
| Checks whether the queue is empty. More... | |
| void | merge (PriorityQueue &other) |
Merges in enqueued values of other queue. More... | |
| PriorityQueue & | operator= (PriorityQueue other) |
| Copy and move assignment. More... | |
| PriorityQueue & | operator= (std::initializer_list< value_type > ilist) |
| Assigns the priority queue contents of the given initializer list. More... | |
| void | pop () |
| Removes the top element from the heap. More... | |
| handle | push (const value_type &value) |
Inserts a new element with given value into the queue. More... | |
| template<class InputIt > | |
| void | push (InputIt first, InputIt last) |
| Inserts new elements specified by the given range. More... | |
| void | push (std::initializer_list< value_type > ilist) |
| Inserts new elements specified by the given initializer list. More... | |
| size_type | size () const |
| Returns the number of enqueued elements. More... | |
| void | swap (PriorityQueue &other) |
| Swaps the contents. More... | |
| const T & | top () const |
| Returns reference to the top element in the queue. More... | |
| const T & | value (handle pos) const |
| Returns the priority of that handle. More... | |
Private Types | |
| using | SpecImpl = Impl< T, C > |
Private Attributes | |
| const C & | m_cmp |
| SpecImpl * | m_impl |
| Underlying heap data structure. More... | |
| size_type | m_size |
| Number of entries. More... | |
Friends | |
| void | swap (PriorityQueue &a, PriorityQueue &b) |
| Swaps the contents. More... | |
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 65 of file PriorityQueue.h.
| using ogdf::PriorityQueue< T, C, Impl >::const_reference = const value_type & |
Definition at line 79 of file PriorityQueue.h.
| using ogdf::PriorityQueue< T, C, Impl >::handle = typename SpecImpl::Handle |
Definition at line 77 of file PriorityQueue.h.
| using ogdf::PriorityQueue< T, C, Impl >::reference = value_type & |
Definition at line 78 of file PriorityQueue.h.
| using ogdf::PriorityQueue< T, C, Impl >::size_type = std::size_t |
Definition at line 67 of file PriorityQueue.h.
|
private |
Definition at line 72 of file PriorityQueue.h.
| using ogdf::PriorityQueue< T, C, Impl >::value_type = T |
Definition at line 76 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 86 of file PriorityQueue.h.
|
inline |
Copy constructor.
Definition at line 92 of file PriorityQueue.h.
|
inline |
Move constructor.
Definition at line 98 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 111 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 122 of file PriorityQueue.h.
|
inline |
Destroys the underlying data structure.
Definition at line 128 of file PriorityQueue.h.
|
inline |
Removes all the entries from the queue.
Definition at line 229 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 212 of file PriorityQueue.h.
|
inline |
Checks whether the queue is empty.
Definition at line 235 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 222 of file PriorityQueue.h.
|
inline |
Copy and move assignment.
Definition at line 133 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 143 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 199 of file PriorityQueue.h.
|
inline |
Inserts a new element with given value into the queue.
Definition at line 170 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 181 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 191 of file PriorityQueue.h.
|
inline |
Returns the number of enqueued elements.
Definition at line 240 of file PriorityQueue.h.
|
inline |
Swaps the contents.
Definition at line 150 of file PriorityQueue.h.
|
inline |
Returns reference to the top element in the queue.
Definition at line 161 of file PriorityQueue.h.
|
inline |
Returns the priority of that handle.
| pos | The handle |
Definition at line 250 of file PriorityQueue.h.
|
friend |
Swaps the contents.
Definition at line 156 of file PriorityQueue.h.
|
private |
Definition at line 71 of file PriorityQueue.h.
|
private |
Underlying heap data structure.
Definition at line 73 of file PriorityQueue.h.
|
private |
Number of entries.
Definition at line 70 of file PriorityQueue.h.