53 template <
class DataT,
54 class SortingAlgorithmT = std::less<DataT>,
60 typename std::conditional<bounded_cnt == 0,
67 using size_type = size_t;
68 using iterator =
typename PQueueType::iterator;
69 using const_iterator =
typename PQueueType::const_iterator;
76 priority_items_(bounded_cnt)
85 priority_items_(bounded_cnt),
96 const auto eit = priority_items_.end();
97 for(
auto it = priority_items_.begin(); it != eit; ++it)
99 if(sort_alg_(data, *it)) {
100 priority_items_.insert(it, data);
104 priority_items_.emplace_back(data);
109 return priority_items_.size();
114 return priority_items_.empty();
118 const DataT &
top()
const {
120 return priority_items_.front();
126 return priority_items_.back();
132 priority_items_.pop_front();
137 priority_items_.clear();
142 priority_items_.remove(data);
146 void erase(
const const_iterator & it) {
147 priority_items_.erase(it);
162 priority_items_.emplace_front(data);
168 iterator
begin() {
return priority_items_.begin(); }
171 const_iterator
begin()
const {
return priority_items_.begin(); }
174 iterator
end() {
return priority_items_.end(); }
177 const_iterator
end()
const {
return priority_items_.end(); }
183 PQueueType priority_items_;
186 SortingAlgorithmT sort_alg_;
File that defines the FastList class – an alternative to std::list when the user knows the size of th...
Set of macros for Sparta assertions. Caught by the framework.
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
A data structure that allows pushing/emplacing into it with a given sorter.
PriorityQueue(const SortingAlgorithmT &sort_alg)
Create a priority queue with a specific instance of the sorting algorithm.
const DataT & back() const
Get the last element (lowest priority) in the queue.
size_t size() const
Get the number of items in the queue.
void remove(const DataT &data)
Remove the item from the queue.
const DataT & top() const
Get the first element in the queue.
bool empty() const
Is the queue empty?
void forceFront(const DataT &data)
Force a data entry to the front of the queue.
void pop()
Pop the front of the queue (highest priority)
void clear()
Clear the entire queue.
void erase(const const_iterator &it)
Erase the item from the queue (const_iterator/iterator)
PriorityQueue()
Create a priority queue with a default instance of the sorting algorithm.
void insert(const DataT &data)
Inserts the data item into the list using the sorting alg. Stops at the first insertion.
An alternative to std::list, about 70% faster.
const_iterator end() const
Const Iterator to end of the queue – end priority.
iterator begin()
Iterator to beginning of the queue – highest priority.
iterator end()
Iterator to end of the queue – end priority.
const_iterator begin() const
Const Iterator to beginning of the queue – highest priority.
Macros for handling exponential backoff.