Public Member Functions | Protected Types | Protected Attributes | List of all members
costmap_queue::MapBasedQueue< item_t > Class Template Reference

Templatized interface for a priority queue. More...

#include <map_based_queue.h>

Public Member Functions

void enqueue (const double priority, item_t item)
 Add a new item to the queue with a set priority. More...
 
item_t & front ()
 Return the item at the front of the queue. More...
 
bool isEmpty ()
 Check to see if there is anything in the queue. More...
 
 MapBasedQueue (bool reset_bins=true)
 Default Constructor. More...
 
void pop ()
 Remove (and destroy) the item at the front of the queue. More...
 
virtual void reset ()
 Clear the queue. More...
 

Protected Types

using ItemMap = std::map< double, std::vector< item_t >>
 
using ItemMapIterator = typename ItemMap::iterator
 

Protected Attributes

ItemMap item_bins_
 
unsigned int item_count_
 
ItemMapIterator iter_
 
ItemMapIterator last_insert_iter_
 
bool reset_bins_
 

Detailed Description

template<class item_t>
class costmap_queue::MapBasedQueue< item_t >

Templatized interface for a priority queue.

This is faster than the std::priority_queue implementation in certain cases because iterating does not require resorting after every element is examined. Based on https://github.com/ros-planning/navigation/pull/525 The relative speed of this against the priority queue depends how many items with each priority are inserted into the queue.

One additional speed up depends on the patterns of priorities during each iteration of the queue. If the same priorities are inserted into the queue on every iteration, then it is quicker to set reset_bins = false, such that the priority bins are not reset and will not have to be recreated on each iteration.

Definition at line 61 of file map_based_queue.h.

Member Typedef Documentation

template<class item_t>
using costmap_queue::MapBasedQueue< item_t >::ItemMap = std::map<double, std::vector<item_t>>
protected

Definition at line 161 of file map_based_queue.h.

template<class item_t>
using costmap_queue::MapBasedQueue< item_t >::ItemMapIterator = typename ItemMap::iterator
protected

Definition at line 162 of file map_based_queue.h.

Constructor & Destructor Documentation

template<class item_t>
costmap_queue::MapBasedQueue< item_t >::MapBasedQueue ( bool  reset_bins = true)
inlineexplicit

Default Constructor.

Definition at line 67 of file map_based_queue.h.

Member Function Documentation

template<class item_t>
void costmap_queue::MapBasedQueue< item_t >::enqueue ( const double  priority,
item_t  item 
)
inline

Add a new item to the queue with a set priority.

Parameters
priorityPriority of the item
itemPayload item

Definition at line 90 of file map_based_queue.h.

template<class item_t>
item_t& costmap_queue::MapBasedQueue< item_t >::front ( )
inline

Return the item at the front of the queue.

Returns
The item at the front of the queue

Definition at line 135 of file map_based_queue.h.

template<class item_t>
bool costmap_queue::MapBasedQueue< item_t >::isEmpty ( )
inline

Check to see if there is anything in the queue.

Returns
True if there is nothing in the queue

Must be called prior to front/pop.

Definition at line 126 of file map_based_queue.h.

template<class item_t>
void costmap_queue::MapBasedQueue< item_t >::pop ( )
inline

Remove (and destroy) the item at the front of the queue.

Definition at line 148 of file map_based_queue.h.

template<class item_t>
virtual void costmap_queue::MapBasedQueue< item_t >::reset ( )
inlinevirtual

Clear the queue.

Reimplemented in costmap_queue::CostmapQueue.

Definition at line 75 of file map_based_queue.h.

Member Data Documentation

template<class item_t>
ItemMap costmap_queue::MapBasedQueue< item_t >::item_bins_
protected

Definition at line 166 of file map_based_queue.h.

template<class item_t>
unsigned int costmap_queue::MapBasedQueue< item_t >::item_count_
protected

Definition at line 167 of file map_based_queue.h.

template<class item_t>
ItemMapIterator costmap_queue::MapBasedQueue< item_t >::iter_
protected

Definition at line 168 of file map_based_queue.h.

template<class item_t>
ItemMapIterator costmap_queue::MapBasedQueue< item_t >::last_insert_iter_
protected

Definition at line 169 of file map_based_queue.h.

template<class item_t>
bool costmap_queue::MapBasedQueue< item_t >::reset_bins_
protected

Definition at line 164 of file map_based_queue.h.


The documentation for this class was generated from the following file:


costmap_queue
Author(s):
autogenerated on Sun Jan 10 2021 04:08:29