|
Z-Wave Protocol Controller Reference
|
Priority Queue. More...
#include <priority_queue.hpp>
Public Types | |
| using | value_type = typename std::decay< T >::type |
| using | iterator = value_type * |
| using | const_iterator = const value_type * |
| using | size_type = int |
Public Member Functions | |
| constexpr | priority_queue ()=default |
| bool | insert (value_type &&item) noexcept |
| inserts a value into the queue. inserts are ordered by their priority. this function takes O(log n) time to do so. More... | |
| value_type | pop_front () noexcept |
| takes the first item in the queue and returns it. The item is deleted from the queue. It panics if the queue is empty. More... | |
| iterator | erase (const_iterator iterator) |
| removes an item from the queue by iterator. Performance: O(log n) More... | |
| constexpr size_type | size () const noexcept |
| constexpr size_type | max_size () const noexcept |
| constexpr bool | empty () const noexcept |
returns if the queue is empty. in this case both begin() and end() point to nullptr More... | |
| constexpr iterator | begin () noexcept |
if queue != empty() it returns a pointer to the beginning of the queue. The item with the highest priority More... | |
| constexpr iterator | end () noexcept |
| iterator that points past the last element in the queue. More... | |
| constexpr const_iterator | begin () const noexcept |
if queue != empty() it returns a pointer to the beginning of the queue. The item with the highest priority More... | |
| constexpr const_iterator | end () const noexcept |
| iterator that points past the last element in the queue. More... | |
| constexpr void | clear () noexcept |
| remove all items from the queue. More... | |
Private Member Functions | |
| constexpr size_type | parent_index (size_type i) const |
| constexpr size_type | left_index (size_type i) const |
| constexpr size_type | right_index (size_type i) const |
| constexpr size_type | biggest_child (size_type current) const |
| void | init_iterators () |
Private Attributes | |
| value_type | elements [Size] |
| iterator | last = nullptr |
| iterator | first = nullptr |
Priority Queue.
This container arranges nodes in a binary tree, with the highest priority (highest value) at the root of the tree. Note that this tree is not lineair sorted! This means that searching the tree will take linear time. Secondly, This class is designed to be used in memory limited environments (read embedded systems). Hence this class operates without allocating any heap memory.
Since only static memory is used, the maximum size of the container needs to determine beforehand. Its up to the implementor to choose a size big enough to accommodate for all use-cases.
The interface of this container should look familiar. It tries to mimic, where possible, the same interface as the containers you would find in the std library.
| using priority_queue< T, Size, KeyGreater >::const_iterator = const value_type * |
| using priority_queue< T, Size, KeyGreater >::iterator = value_type * |
| using priority_queue< T, Size, KeyGreater >::size_type = int |
| using priority_queue< T, Size, KeyGreater >::value_type = typename std::decay<T>::type |
|
constexprdefault |
|
inlineconstexprnoexcept |
if queue != empty() it returns a pointer to the beginning of the queue. The item with the highest priority
nullptr in the case the queue is empty
|
inlineconstexprnoexcept |
if queue != empty() it returns a pointer to the beginning of the queue. The item with the highest priority
nullptr in the case the queue is empty
|
inlineconstexprprivate |
|
inlineconstexprnoexcept |
remove all items from the queue.
Performance : O(1)
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
iterator that points past the last element in the queue.
nullptr in the case the queue is empty
|
inlineconstexprnoexcept |
iterator that points past the last element in the queue.
nullptr in the case the queue is empty
|
inline |
removes an item from the queue by iterator. Performance: O(log n)
|
inlineprivate |
|
inlinenoexcept |
inserts a value into the queue. inserts are ordered by their priority. this function takes O(log n) time to do so.
Be aware that this container cannot grow past its max size of max_size(). this function will return false in this case!
|
inlineconstexprprivate |
|
inlineconstexprnoexcept |
|
inlineconstexprprivate |
|
inlinenoexcept |
takes the first item in the queue and returns it. The item is deleted from the queue. It panics if the queue is empty.
after this operation the priority in the queue is maintained.
Performance: O(log n)
|
inlineconstexprprivate |
|
inlineconstexprnoexcept |
|
private |
|
private |
|
private |