|
Ponca
6d7f3619cbd70eb6ac131a3267ba1a351b1c9d07
Point Cloud Analysis library
|
The LimitedPriorityQueue class is similar to std::priority_queue but has a limited capacity and handles the comparison differently. More...
#include <limitedPriorityQueue.h>
Inheritance diagram for Ponca::LimitedPriorityQueue< T, N, CompareT >:
Collaboration diagram for Ponca::LimitedPriorityQueue< T, N, CompareT >:Public Types | |
| using | value_type = T |
| using | container_type = std::array< T, N > |
| using | compare = CompareT |
| using | iterator = typename container_type::iterator |
| using | const_iterator = typename container_type::const_iterator |
| using | Self = LimitedPriorityQueue< T, N, CompareT > |
Public Member Functions | |
| LimitedPriorityQueue (const Self &other) | |
| LimitedPriorityQueue (int capacity) | |
| template<class InputIt > | |
| LimitedPriorityQueue (int capacity, InputIt first, InputIt last) | |
| LimitedPriorityQueue & | operator= (const Self &other)=default |
| iterator | begin () |
| const_iterator | begin () const |
| const_iterator | cbegin () const |
| iterator | end () |
| const_iterator | end () const |
| const_iterator | cend () const |
| const T & | top () const |
| const T & | bottom () const |
| T & | top () |
| T & | bottom () |
| bool | empty () const |
| bool | full () const |
| size_t | size () const |
| size_t | capacity () const |
| bool | push (T &&_value) |
| bool | push (const T &_value) |
| void | pop () |
| void | reserve (int _capacity) |
| void | clear () |
| const container_type & | container () const |
Protected Member Functions | |
| bool | pushImpl (const T &_value, T **_addr) |
Protected Attributes | |
| container_type | m_data {} |
| compare | m_comp |
| size_t | m_size {0} |
| The current size of the Queue. | |
| size_t | m_capacity {0} |
| The capacity of the limited queue. | |
The LimitedPriorityQueue class is similar to std::priority_queue but has a limited capacity and handles the comparison differently.
In case the capacity is reached, the container is full and push() do not insert a new element if its priority is lower than the current minimal one.
The comparison predicate must return true is the first argument has priority on the second one.
The element with the highest priority is the last one that is pop out, but is the first one that is iterated through.
Example 1: Using std::less as comparison predicate, we have the following situation:
full() = false empty() = false capacity() = 6 size() = 4 top() = 1 bottom() = 9 pop() removes the value 9 push(4) adds the value 4 begin end v v +---+---+---+---+---+---+ | 1 | 3 | 8 | 9 | | | +---+---+---+---+---+---+ ^ ^ top bottom
Example 2: Using std::greater as comparison predicate, we have the following situation:
full() = true empty() = false capacity() = 6 size() = 6 top() = 9 bottom() = 2 begin end v v +---+---+---+---+---+---+ | 9 | 8 | 6 | 4 | 3 | 2 | +---+---+---+---+---+---+ ^ ^ top bottom pop() removes the value 2 push(5) adds the value 5 and remove the value 2 push(0) do nothing
| T | The data type stored in the queue |
| N | The maximum capacity of the queue |
| CompareT | A binary predicate used to sort the queue. Default to less |
Definition at line 84 of file limitedPriorityQueue.h.
| using Ponca::LimitedPriorityQueue< T, N, CompareT >::compare = CompareT |
Definition at line 91 of file limitedPriorityQueue.h.
| using Ponca::LimitedPriorityQueue< T, N, CompareT >::const_iterator = typename container_type::const_iterator |
Definition at line 93 of file limitedPriorityQueue.h.
| using Ponca::LimitedPriorityQueue< T, N, CompareT >::container_type = std::array<T, N> |
Definition at line 90 of file limitedPriorityQueue.h.
| using Ponca::LimitedPriorityQueue< T, N, CompareT >::iterator = typename container_type::iterator |
Definition at line 92 of file limitedPriorityQueue.h.
| using Ponca::LimitedPriorityQueue< T, N, CompareT >::Self = LimitedPriorityQueue<T, N, CompareT> |
Definition at line 94 of file limitedPriorityQueue.h.
| using Ponca::LimitedPriorityQueue< T, N, CompareT >::value_type = T |
Definition at line 89 of file limitedPriorityQueue.h.
|
inline |
Definition at line 163 of file limitedPriorityQueue.h.
|
inline |
Definition at line 169 of file limitedPriorityQueue.h.
|
inlineexplicit |
Definition at line 176 of file limitedPriorityQueue.h.
| Ponca::LimitedPriorityQueue< T, N, Cmp >::LimitedPriorityQueue | ( | int | capacity, |
| InputIt | first, | ||
| InputIt | last | ||
| ) |
Definition at line 185 of file limitedPriorityQueue.h.
|
inline |
Definition at line 13 of file limitedPriorityQueue.hpp.
|
inline |
Definition at line 19 of file limitedPriorityQueue.hpp.
|
inline |
Definition at line 69 of file limitedPriorityQueue.hpp.
|
inline |
Definition at line 57 of file limitedPriorityQueue.hpp.
|
inline |
Definition at line 95 of file limitedPriorityQueue.hpp.
|
inline |
Definition at line 25 of file limitedPriorityQueue.hpp.
|
inline |
Definition at line 43 of file limitedPriorityQueue.hpp.
Definition at line 180 of file limitedPriorityQueue.hpp.
| const LimitedPriorityQueue< T, N, Cmp >::container_type & Ponca::LimitedPriorityQueue< T, N, Cmp >::container | ( | ) | const |
Definition at line 188 of file limitedPriorityQueue.hpp.
|
inline |
Definition at line 77 of file limitedPriorityQueue.hpp.
|
inline |
Definition at line 31 of file limitedPriorityQueue.hpp.
|
inline |
Definition at line 37 of file limitedPriorityQueue.hpp.
|
inline |
Definition at line 83 of file limitedPriorityQueue.hpp.
Definition at line 164 of file limitedPriorityQueue.hpp.
| bool Ponca::LimitedPriorityQueue< T, N, Cmp >::push | ( | const T & | _value | ) |
Definition at line 152 of file limitedPriorityQueue.hpp.
| bool Ponca::LimitedPriorityQueue< T, N, Cmp >::push | ( | T && | _value | ) |
Definition at line 140 of file limitedPriorityQueue.hpp.
|
inlineprotected |
Definition at line 102 of file limitedPriorityQueue.hpp.
| void Ponca::LimitedPriorityQueue< T, N, Cmp >::reserve | ( | int | _capacity | ) |
Definition at line 170 of file limitedPriorityQueue.hpp.
|
inline |
Definition at line 89 of file limitedPriorityQueue.hpp.
Definition at line 63 of file limitedPriorityQueue.hpp.
|
inline |
Definition at line 51 of file limitedPriorityQueue.hpp.
|
protected |
The capacity of the limited queue.
Definition at line 152 of file limitedPriorityQueue.h.
|
protected |
Definition at line 150 of file limitedPriorityQueue.h.
|
protected |
Definition at line 149 of file limitedPriorityQueue.h.
|
protected |
The current size of the Queue.
Definition at line 151 of file limitedPriorityQueue.h.