Ocular Engine
Ocular::Utils::CircularQueue< T, MAX_ELEMENTS > Class Template Reference

#include <CircularQueue.hpp>

Public Member Functions

 CircularQueue ()
 
bool enqueue (T const element)
 
bool dequeue (T &retElement)
 
bool dequeue ()
 
bool peek (T &retElement)
 
unsigned getNumElements () const
 
void clear ()
 

Detailed Description

template<typename T, std::size_t MAX_ELEMENTS>
class Ocular::Utils::CircularQueue< T, MAX_ELEMENTS >

Implementation of a circular queue with O(1) push and pop.

Constructor & Destructor Documentation

template<typename T, std::size_t MAX_ELEMENTS>
Ocular::Utils::CircularQueue< T, MAX_ELEMENTS >::CircularQueue ( )
inline
Parameters
[in]sizeStarting size of the internal array.

Member Function Documentation

template<typename T, std::size_t MAX_ELEMENTS>
void Ocular::Utils::CircularQueue< T, MAX_ELEMENTS >::clear ( )
inline

Removes all elements from the queue.

template<typename T, std::size_t MAX_ELEMENTS>
bool Ocular::Utils::CircularQueue< T, MAX_ELEMENTS >::dequeue ( T &  retElement)
inline

Dequeues an element from the queue if it is not empty.

Parameters
[out]retElementThe element removed from the queue.
Returns
TRUE if an element was successfully dequeued.
template<typename T, std::size_t MAX_ELEMENTS>
bool Ocular::Utils::CircularQueue< T, MAX_ELEMENTS >::enqueue ( T const  element)
inline

Adds the element to the queue.

Returns
TRUE if successfully enqueued.
template<typename T, std::size_t MAX_ELEMENTS>
unsigned Ocular::Utils::CircularQueue< T, MAX_ELEMENTS >::getNumElements ( ) const
inline
Returns
Current number of elements in the queue.
template<typename T, std::size_t MAX_ELEMENTS>
bool Ocular::Utils::CircularQueue< T, MAX_ELEMENTS >::peek ( T &  retElement)
inline
Parameters
[out]retElementElement at the front of the queue.
Returns
TRUE if an element is available to view.

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