ls1-MarDyn
ls1-MarDyn molecular dynamics code
Public Member Functions | List of all members
FixedSizeQueue< T > Class Template Reference

#include <FixedSizeQueue.h>

Public Member Functions

 FixedSizeQueue (size_t capacity=1ul)
 
void setCapacity (size_t new_capacity)
 
void insert (const T &t)
 
auto begin ()
 
auto begin () const
 
auto end ()
 
auto end () const
 
size_t size () const
 

Detailed Description

template<typename T>
class FixedSizeQueue< T >

This class implements a FIFO queue with a specified capacity. It additionally provides iteration over the entire queue. The oldest entries are overwritten if new entries are added if the maximal capacity has been reached.

Template Parameters
TThe type of elements to store.
Note
This is not the most efficient implementation! For a more efficient implementation, a std::vector should be used. In that case, either an own iterator class is needed or the order of the elements is lost through the iterators.

Constructor & Destructor Documentation

◆ FixedSizeQueue()

template<typename T >
FixedSizeQueue< T >::FixedSizeQueue ( size_t  capacity = 1ul)
inlineexplicit

Constructor.

Parameters
capacityThe number of history entries that can be stored.

Member Function Documentation

◆ begin() [1/2]

template<typename T >
auto FixedSizeQueue< T >::begin ( )
inline

Returns the begin iterator. This initially points to the oldest entry.

Returns
The iterator.

◆ begin() [2/2]

template<typename T >
auto FixedSizeQueue< T >::begin ( ) const
inline

Note
const version

◆ end() [1/2]

template<typename T >
auto FixedSizeQueue< T >::end ( )
inline

Returns the end iterator.

Returns

◆ end() [2/2]

template<typename T >
auto FixedSizeQueue< T >::end ( ) const
inline

Note
const version

◆ insert()

template<typename T >
void FixedSizeQueue< T >::insert ( const T &  t)
inline

Inserts an element. Potentially deletes old elements if the capacity was reached.

Parameters
t

◆ setCapacity()

template<typename T >
void FixedSizeQueue< T >::setCapacity ( size_t  new_capacity)
inline

Sets the capacity to new_capacity.

Parameters
new_capacity

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