SolidUtils
Classes | Public Member Functions | Static Public Attributes | List of all members
sl::FixedPriorityQueue< K, V > Class Template Reference

The FixedPriorityQueue class provides a priority queue implementation with the standard O(log n) insertion, deletion, pop, and update operations, but in addition can perform non-modifying queries in O(1) time. More...

#include <FixedPriorityQueue.hpp>

Classes

class  ValueSet
 

Public Member Functions

 FixedPriorityQueue (V const max)
 Create a new priority queue that can hold element 0 through max. More...
 
void remove (V const value) noexcept
 Remove an element from the queue. More...
 
void add (K const key, V const value) noexcept
 Add an value to the queue. More...
 
void update (K const key, V const value) noexcept
 Update the key associated with a given value. More...
 
void updateByDelta (K const delta, V const value) noexcept
 Update the key associated with a given value by modifying the key. More...
 
bool contains (V const value) const noexcept
 Check if a value in present in the priority queue. More...
 
get (V const value) const noexcept
 Get the key associated with the given value. More...
 
pop () noexcept
 Pop the top value from the queue. More...
 
V const & peek () const noexcept
 Get get the top of the priority queue's value. More...
 
K const & max () const noexcept
 Get get the top of the priority queue's value. More...
 
size_t size () const noexcept
 Get the number of elements in the queue. More...
 
void clear () noexcept
 Clear entries from the priority queue.
 
ValueSet remaining () const noexcept
 Get the set of remaining items in the priority. The order of the values is arbitrary. More...
 

Static Public Attributes

static constexpr size_t const NULL_INDEX = static_cast<size_t>(-1)
 

Detailed Description

template<typename K, typename V>
class sl::FixedPriorityQueue< K, V >

The FixedPriorityQueue class provides a priority queue implementation with the standard O(log n) insertion, deletion, pop, and update operations, but in addition can perform non-modifying queries in O(1) time.

Template Parameters
KThe key type.
VThe value type.

Constructor & Destructor Documentation

◆ FixedPriorityQueue()

template<typename K, typename V>
sl::FixedPriorityQueue< K, V >::FixedPriorityQueue ( V const  max)
inline

Create a new priority queue that can hold element 0 through max.

Parameters
maxThe max value in the priority queue (exclusive).

Member Function Documentation

◆ add()

template<typename K, typename V>
void sl::FixedPriorityQueue< K, V >::add ( K const  key,
V const  value 
)
inlinenoexcept

Add an value to the queue.

Parameters
keyThe key/priority of the value to add.
valueThe value to add.

◆ contains()

template<typename K, typename V>
bool sl::FixedPriorityQueue< K, V >::contains ( V const  value) const
inlinenoexcept

Check if a value in present in the priority queue.

Parameters
valueThe value to check for.
Returns
Whether or not the value is present.

◆ get()

template<typename K, typename V>
K sl::FixedPriorityQueue< K, V >::get ( V const  value) const
inlinenoexcept

Get the key associated with the given value.

Parameters
valueThe value.
Returns
The key.

◆ max()

template<typename K, typename V>
K const& sl::FixedPriorityQueue< K, V >::max ( ) const
inlinenoexcept

Get get the top of the priority queue's value.

Returns
The value.

◆ peek()

template<typename K, typename V>
V const& sl::FixedPriorityQueue< K, V >::peek ( ) const
inlinenoexcept

Get get the top of the priority queue's value.

Returns
The value.

◆ pop()

template<typename K, typename V>
V sl::FixedPriorityQueue< K, V >::pop ( )
inlinenoexcept

Pop the top value from the queue.

Returns
The top value.

◆ remaining()

template<typename K, typename V>
ValueSet sl::FixedPriorityQueue< K, V >::remaining ( ) const
inlinenoexcept

Get the set of remaining items in the priority. The order of the values is arbitrary.

Returns
The set of values.

◆ remove()

template<typename K, typename V>
void sl::FixedPriorityQueue< K, V >::remove ( V const  value)
inlinenoexcept

Remove an element from the queue.

Parameters
elemThe element to remove

◆ size()

template<typename K, typename V>
size_t sl::FixedPriorityQueue< K, V >::size ( ) const
inlinenoexcept

Get the number of elements in the queue.

Returns
The number of elements.

◆ update()

template<typename K, typename V>
void sl::FixedPriorityQueue< K, V >::update ( K const  key,
V const  value 
)
inlinenoexcept

Update the key associated with a given value.

Parameters
keyThe new key for the value.
valueThe value.

◆ updateByDelta()

template<typename K, typename V>
void sl::FixedPriorityQueue< K, V >::updateByDelta ( K const  delta,
V const  value 
)
inlinenoexcept

Update the key associated with a given value by modifying the key.

Parameters
deltaThe change in priority.
valueThe value.

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