Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::ContiguousQueue< T, N > Class Template Reference

#include <contiguous_queue.h>

Public Member Functions

 ContiguousQueue ()
 
T * addEnd ()
 
T * removeEnd ()
 
const T * removeEnd () const
 
unsigned int availableToAdd () const
 
unsigned int availableToRemove () const
 
void added (unsigned int n)
 
void removed (unsigned int n)
 

Detailed Description

template<typename T, unsigned N>
class Boardcore::ContiguousQueue< T, N >

A fixed size FIFO queue whose elements are stored in a contiguous array, which allows direct access to the array in order to add/remove multiple elements.

NOTE: This queue is most efficent if the data is removed form the queue in large chunks. Removing one element at a time is most inefficient since shifting all the other elements in the queue is needed. There are no performance constraints on inserting.

The queue is not synchronized.

Parameters
Ttype of the element
Nmaximum number of elements (fixed size queue)

Definition at line 46 of file contiguous_queue.h.

Constructor & Destructor Documentation

◆ ContiguousQueue()

template<typename T , unsigned N>
Boardcore::ContiguousQueue< T, N >::ContiguousQueue ( )
inline

Constructor

Definition at line 52 of file contiguous_queue.h.

Member Function Documentation

◆ added()

template<typename T , unsigned N>
void Boardcore::ContiguousQueue< T, N >::added ( unsigned int n)
inline

After having added elements to the pointer obtained through addEnd(), call this function to let the queue know how many elements have been added

Parameters
nelements added
Exceptions
range_errorif too many elements were addded. Memory corruption has already occurred at this point, though

Definition at line 104 of file contiguous_queue.h.

◆ addEnd()

template<typename T , unsigned N>
T * Boardcore::ContiguousQueue< T, N >::addEnd ( )
inline
Returns
a pointer to the side of the queue where elements can be added. Call availableToAdd() to know how much space is left. The pointer is meant to be used as an array, so as to add more than one item.

NOTE: if availableToAdd() returns 0 the pointer is past the end of the array and should not be dereferenced

Definition at line 62 of file contiguous_queue.h.

◆ availableToAdd()

template<typename T , unsigned N>
unsigned int Boardcore::ContiguousQueue< T, N >::availableToAdd ( ) const
inline
Returns
how much space is available to add elements

Definition at line 89 of file contiguous_queue.h.

◆ availableToRemove()

template<typename T , unsigned N>
unsigned int Boardcore::ContiguousQueue< T, N >::availableToRemove ( ) const
inline
Returns
how many items are available to read

Definition at line 94 of file contiguous_queue.h.

◆ removed()

template<typename T , unsigned N>
void Boardcore::ContiguousQueue< T, N >::removed ( unsigned int n)
inline

After having removed elements to the pointer obtained through removeEnd(), call this function to let the queue know how many elements have been added removed

Parameters
nelements removed
Exceptions
range_errorif too many elements were removed. Memory corruption has already occurred at this point, though

Definition at line 119 of file contiguous_queue.h.

◆ removeEnd() [1/2]

template<typename T , unsigned N>
T * Boardcore::ContiguousQueue< T, N >::removeEnd ( )
inline
Returns
a pointer to the side of the queue where elements can be removed. Call availableToRemove() to know how many elements are available. The pointer is meant to be used as an array, so as to read more than one item.

NOTE: if availableToRemove() returns 0 the pointer should not be dereferenced

Definition at line 73 of file contiguous_queue.h.

◆ removeEnd() [2/2]

template<typename T , unsigned N>
const T * Boardcore::ContiguousQueue< T, N >::removeEnd ( ) const
inline
Returns
a pointer to the side of the queue where elements can be removed. Call availableToRemove() to know how many elements are available. The pointer is meant to be used as an array, so as to read more than one item.

NOTE: if availableToRemove() returns 0 the pointer should not be dereferenced

Definition at line 84 of file contiguous_queue.h.


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