Support Forum       G3D Web Page     
Public Member Functions | List of all members
G3D::Queue< T > Class Template Reference


Dynamic queue that uses a circular buffer for performance. More...

Public Member Functions

 Queue ()
 
 Queue (const Queue &other)
 
Copy constructor More...
 
virtual ~Queue ()
 
Destructor does not delete() the objects if T is a pointer type (e.g. More...
 
void clear (bool freeStorage=true)
 
Removes all elements (invoking their destructors). More...
 
bool contains (const T &e) const
 
Returns true if the given element is in the queue. More...
 
void copyInto (T *array) const
 Copies the elements of the queue into the array, which must be large enough to hold all elements. More...
 
void deleteAll ()
 
Calls delete on all objects[0...size-1] and sets the queue size to zero. More...
 
dequeue ()
 
popFront More...
 
bool empty () const
 
void enqueue (const T &e)
 
pushBack More...
 
void fastClear ()
 Clear without freeing the underlying array. More...
 
const T & last () const
 Returns the back element. More...
 
T & last ()
 
int length () const
 
Number of elements in the queue. More...
 
Queueoperator= (const Queue &other)
 
Assignment operator. More...
 
T & operator[] (int n)
 
Performs bounds checks in debug mode More...
 
const T & operator[] (int n) const
 
Performs bounds checks in debug mode More...
 
popBack ()
 
Remove the last element from the queue. More...
 
popFront ()
 
Remove the next element from the head of the queue. More...
 
void pushBack (const T &e)
 
Insert a new element at the end of the queue. More...
 
void pushFront (const T &e)
 
Insert a new element into the front of the queue (a traditional queue only uses pushBack). More...
 
int size () const
 
Number of elements in the queue. More...
 

Detailed Description

template<class T>
class G3D::Queue< T >


Dynamic queue that uses a circular buffer for performance.

Faster than std::deque for objects with constructors.

Constructor & Destructor Documentation

◆ Queue() [1/2]

template<class T>
G3D::Queue< T >::Queue ( )
inline

◆ Queue() [2/2]

template<class T>
G3D::Queue< T >::Queue ( const Queue< T > &  other)
inline


Copy constructor

◆ ~Queue()

template<class T>
virtual G3D::Queue< T >::~Queue ( )
inlinevirtual


Destructor does not delete() the objects if T is a pointer type (e.g.

T = int*) instead, it deletes the pointers themselves and leaves the objects. Call deleteAll if you want to dealocate the objects referenced.

Member Function Documentation

◆ clear()

template<class T>
void G3D::Queue< T >::clear ( bool  freeStorage = true)
inline


Removes all elements (invoking their destructors).

Parameters
freeStorageIf false, the underlying array is not deallocated (allowing fast push in the future), however, the size of the Queue is reported as zero.

Referenced by G3D::ThreadsafeQueue< G3D::_internal::NetworkCallbackInfo >::clear(), G3D::TimeQueue< T >::clear(), G3D::Queue< G3D::_internal::NetworkCallbackInfo >::deleteAll(), G3D::Queue< G3D::_internal::NetworkCallbackInfo >::fastClear(), G3D::Queue< G3D::_internal::NetworkCallbackInfo >::operator=(), and G3D::Queue< G3D::_internal::NetworkCallbackInfo >::~Queue().

◆ contains()

template<class T>
bool G3D::Queue< T >::contains ( const T &  e) const
inline


Returns true if the given element is in the queue.

◆ copyInto()

template<class T>
void G3D::Queue< T >::copyInto ( T *  array) const
inline

Copies the elements of the queue into the array, which must be large enough to hold all elements.

◆ deleteAll()

template<class T>
void G3D::Queue< T >::deleteAll ( )
inline


Calls delete on all objects[0...size-1] and sets the queue size to zero.

◆ dequeue()

template<class T>
T G3D::Queue< T >::dequeue ( )
inline


popFront

◆ empty()

template<class T>
bool G3D::Queue< T >::empty ( ) const
inline

◆ enqueue()

template<class T>
void G3D::Queue< T >::enqueue ( const T &  e)
inline


pushBack

◆ fastClear()

template<class T>
void G3D::Queue< T >::fastClear ( )
inline

Clear without freeing the underlying array.

◆ last() [1/2]

template<class T>
const T& G3D::Queue< T >::last ( ) const
inline

Returns the back element.

Referenced by G3D::TimeQueue< T >::getPopBack().

◆ last() [2/2]

template<class T>
T& G3D::Queue< T >::last ( )
inline

◆ length()

template<class T>
int G3D::Queue< T >::length ( ) const
inline


Number of elements in the queue.

◆ operator=()

template<class T>
Queue& G3D::Queue< T >::operator= ( const Queue< T > &  other)
inline


Assignment operator.

◆ operator[]() [1/2]

template<class T>
T& G3D::Queue< T >::operator[] ( int  n)
inline


Performs bounds checks in debug mode

◆ operator[]() [2/2]

template<class T>
const T& G3D::Queue< T >::operator[] ( int  n) const
inline


Performs bounds checks in debug mode

◆ popBack()

template<class T>
T G3D::Queue< T >::popBack ( )
inline


Remove the last element from the queue.

The queue will never shrink in size. (A typical queue only uses popFront).

Referenced by G3D::TimeQueue< T >::getPopBack(), and G3D::ThreadsafeQueue< G3D::_internal::NetworkCallbackInfo >::popBack().

◆ popFront()

template<class T>
T G3D::Queue< T >::popFront ( )
inline


Remove the next element from the head of the queue.

The queue will never shrink in size.

Referenced by G3D::Queue< G3D::_internal::NetworkCallbackInfo >::dequeue(), G3D::TimeQueue< T >::getPopFront(), and G3D::ThreadsafeQueue< G3D::_internal::NetworkCallbackInfo >::popFront().

◆ pushBack()

template<class T>
void G3D::Queue< T >::pushBack ( const T &  e)
inline

◆ pushFront()

template<class T>
void G3D::Queue< T >::pushFront ( const T &  e)
inline


Insert a new element into the front of the queue (a traditional queue only uses pushBack).

Referenced by G3D::ThreadsafeQueue< G3D::_internal::NetworkCallbackInfo >::pushFront(), and G3D::TimeQueue< T >::pushFront().

◆ size()

template<class T>
int G3D::Queue< T >::size ( ) const
inline

documentation generated on Wed Nov 24 2021 08:01:59 using doxygen 1.8.15