Base Framework
Public Types | Public Member Functions | Protected Attributes | List of all members
PriorityQueue< VALUE, PRIORITY, LOCK > Class Template Reference

Priority queue collection. More...

#include <base/collection/PriorityQueue.h>

Inherits Collection, and Synchronizeable< Unsafe >.

Public Types

typedef VALUE Value
 
typedef PRIORITY Priority
 
typedef Association< Priority, Queue< Value > > Node
 

Public Member Functions

 PriorityQueue () noexcept
 
 PriorityQueue (std::initializer_list< Pair< Priority, Value > > values)
 
 PriorityQueue (const PriorityQueue &copy) noexcept
 
 PriorityQueue (PriorityQueue &&move) noexcept
 
PriorityQueueoperator= (const PriorityQueue &assign)
 
PriorityQueueoperator= (PriorityQueue &&assign)
 
MemorySize getSize () const noexcept
 
bool isEmpty () const noexcept
 
void push (const Priority &priority, const Value &value)
 
void push (const Priority &priority, Value &&value)
 
Value pop ()
 
void removeAll () noexcept
 

Protected Attributes

OrderedBinaryTree< Nodeelements
 
MemorySize size = 0
 

Additional Inherited Members

- Protected Member Functions inherited from Synchronizeable< Unsafe >
void exclusiveLock () const noexcept
 
void sharedLock () const noexcept
 
void releaseLock () const noexcept
 

Detailed Description

template<class VALUE, class PRIORITY = int, class LOCK = Unsafe>
class PriorityQueue< VALUE, PRIORITY, LOCK >

Priority queue collection.

Priority queue. As for the Queue collection the first value pushed onto the queue is also the first to be pop'ed. However, values associated with higher priority get to the top before values of less priority.

See also
Queue
Version
1.0

Member Typedef Documentation

◆ Node

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
typedef Association<Priority, Queue<Value> > PriorityQueue< VALUE, PRIORITY, LOCK >::Node

The type of an association used internally by the priority queue.

◆ Priority

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
typedef PRIORITY PriorityQueue< VALUE, PRIORITY, LOCK >::Priority

The type of the priority.

◆ Value

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
typedef VALUE PriorityQueue< VALUE, PRIORITY, LOCK >::Value

The type of a value of the queue.

Constructor & Destructor Documentation

◆ PriorityQueue() [1/4]

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
PriorityQueue< VALUE, PRIORITY, LOCK >::PriorityQueue ( )
inlinenoexcept

Initializes an empty priority queue.

◆ PriorityQueue() [2/4]

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
PriorityQueue< VALUE, PRIORITY, LOCK >::PriorityQueue ( std::initializer_list< Pair< Priority, Value > >  values)
inline

Initializes list from initializer list.

◆ PriorityQueue() [3/4]

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
PriorityQueue< VALUE, PRIORITY, LOCK >::PriorityQueue ( const PriorityQueue< VALUE, PRIORITY, LOCK > &  copy)
inlinenoexcept

Initializes a priority queue from other priority queue.

◆ PriorityQueue() [4/4]

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
PriorityQueue< VALUE, PRIORITY, LOCK >::PriorityQueue ( PriorityQueue< VALUE, PRIORITY, LOCK > &&  move)
inlinenoexcept

Initializes a priority queue from other priority queue.

Member Function Documentation

◆ getSize()

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
MemorySize PriorityQueue< VALUE, PRIORITY, LOCK >::getSize ( ) const
inlinenoexcept

Returns the number of elements in the priority queue.

◆ isEmpty()

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
bool PriorityQueue< VALUE, PRIORITY, LOCK >::isEmpty ( ) const
inlinenoexcept

Returns true if the priority queue is empty.

◆ operator=() [1/2]

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
PriorityQueue& PriorityQueue< VALUE, PRIORITY, LOCK >::operator= ( const PriorityQueue< VALUE, PRIORITY, LOCK > &  assign)
inline

Assign container.

◆ operator=() [2/2]

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
PriorityQueue& PriorityQueue< VALUE, PRIORITY, LOCK >::operator= ( PriorityQueue< VALUE, PRIORITY, LOCK > &&  assign)
inline

Assign container.

◆ pop()

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
Value PriorityQueue< VALUE, PRIORITY, LOCK >::pop ( )
inline

Removes the element at the front of the priority queue. Raises InvalidNode if the priority queue is empty.

◆ push() [1/2]

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
void PriorityQueue< VALUE, PRIORITY, LOCK >::push ( const Priority priority,
const Value value 
)
inline

Pushes the specified value onto the priority queue.

Parameters
priorityThe priority of the value.
valueThe value to be added to the queue.

◆ push() [2/2]

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
void PriorityQueue< VALUE, PRIORITY, LOCK >::push ( const Priority priority,
Value &&  value 
)
inline

Pushes the specified value onto the priority queue.

Parameters
priorityThe priority of the value.
valueThe value to be added to the queue.

◆ removeAll()

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
void PriorityQueue< VALUE, PRIORITY, LOCK >::removeAll ( )
inlinenoexcept

Removes all the keys from this set.

Member Data Documentation

◆ elements

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
OrderedBinaryTree<Node> PriorityQueue< VALUE, PRIORITY, LOCK >::elements
protected

The elements of the priority queue.

◆ size

template<class VALUE , class PRIORITY = int, class LOCK = Unsafe>
MemorySize PriorityQueue< VALUE, PRIORITY, LOCK >::size = 0
protected

The number of elements in the priority queue.