BoundedPriorityDeque
A lightweight, performant bounded priority deque with wide
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
BoundedMaxPriorityDeque< K, V > Class Template Reference

Lightweight maximum priority dequeue. More...

#include <BoundedPriorityDeque.hpp>

Inheritance diagram for BoundedMaxPriorityDeque< K, V >:
BoundedPriorityDequeBase< K, V >

Public Member Functions

 BoundedMaxPriorityDeque (unsigned int capacity=0)
 
- Public Member Functions inherited from BoundedPriorityDequeBase< K, V >
 BoundedPriorityDequeBase (size_t capacity=0)
 Primary constructor with default bounding capacity of zero.
 
BoundingPair< K, V > top () const
 Get the highest-priority element.
 
BoundingPair< K, V > bottom () const
 Get the lowest-priority element.
 
topK () const
 Get the key from the highest-priority element.
 
bottomK () const
 Get the key from the lowest-priority element.
 
void emplace (K key, const V &value)
 constructs a BoundingPair<K, V> element and inserts it.
 
void push (const BoundingPair< K, V > &element)
 Inserts an element into the vector.
 
BoundingPair< K, V > operator[] (size_t offsetTop) const
 random accessor relative to the top of the deque.
 
BoundingPair< K, V > pop ()
 remove the highest-priority element.
 
BoundingPair< K, V > popBottom ()
 remove the lowest-priority element.
 
void operator+= (const BoundedPriorityDequeBase< K, V > &rhs)
 Merges another BoundedPriorityDeque instance into the calling instance.
 
void clear ()
 clears and resets the data structure.
 
size_t size () const
 
size_t capacity () const
 
bool empty () const
 
bool full () const
 
void resize (size_t k)
 Sets the capacity and restores clean state.
 

Protected Member Functions

bool compare (K a, K b) const override
 
- Protected Member Functions inherited from BoundedPriorityDequeBase< K, V >
size_t nextIndex (size_t current) const
 Provides fast access to the next index of a given insertion position.
 
size_t prevIndex (size_t current) const
 Provides fast access to the previous index of a given insertion position.
 
size_t binarySearch (const BoundingPair< K, V > &target) const
 Efficiently locates the optimal insertion index.
 
void insert (const BoundingPair< K, V > &element)
 Inserts an element into the _buffer.
 
void _popTop ()
 Internal method with no return val.
 
void _popBottom ()
 Internal method with no return val.
 

Additional Inherited Members

- Protected Attributes inherited from BoundedPriorityDequeBase< K, V >
std::vector< BoundingPair< K, V > > _buffer
 
size_t _k
 
size_t _size = 0
 
size_t _head = 0
 
size_t _tail = 0
 

Detailed Description

template<typename K, typename V>
class BoundedMaxPriorityDeque< K, V >

Lightweight maximum priority dequeue.

This class provides a lightweight maximum priority implement of the base class with an arithmetic key value.

Template Parameters
KArithmetic type of the key.
VType of the value.

Member Function Documentation

◆ compare()

template<typename K , typename V >
bool BoundedMaxPriorityDeque< K, V >::compare ( a,
b 
) const
inlineoverrideprotectedvirtual

Compares two keys.

Parameters
aThe first key.
bThe second key.
Returns
True if a is considered less than b in a min-oriented deque, or more in a max-oriented deque.

Implements BoundedPriorityDequeBase< K, V >.


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