CircularQueue< T > Class Template Reference

Circular queue implementation. More...

#include <CircularQueue.h>

Inheritance diagram for CircularQueue< T >:

Inheritance graph
[legend]
Collaboration diagram for CircularQueue< T >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 CircularQueue (size_t size, T v)
 Creates a circular queue with a specified size.
virtual ~CircularQueue ()
T & get (int position=0) const
 Returns a reference of an element in the queue from a specified position.
void put (const T &elem)
 Puts new element at the tail of the queue.
void moveMark (int steps)
 Moves the mark of the queue forward for specific number of steps.
T & getFromMark (int position) const
 Returns a reference of an element in the queue from a calculated position.
void reset (T v)
void putArray (double *arr, int len)

Protected Attributes

size_t _size
unsigned current
unsigned currentMark
T * entry


Detailed Description

template<class T>
class CircularQueue< T >

Circular queue implementation.

A fixed size circular queue implementation.

Objects of type T are stored in the queue. The class T must have default constructor.

Definition at line 23 of file CircularQueue.h.


Constructor & Destructor Documentation

template<class T>
CircularQueue< T >::CircularQueue ( size_t  size,
v 
) [inline]

Creates a circular queue with a specified size.

The queue is initialized with size T() objects.

Definition at line 75 of file CircularQueue.h.

References CircularQueue< T >::_size, CircularQueue< T >::entry, and CircularQueue< T >::reset().

Here is the call graph for this function:

template<class T>
CircularQueue< T >::~CircularQueue (  )  [inline, virtual]

Definition at line 84 of file CircularQueue.h.

References CircularQueue< T >::entry.


Member Function Documentation

template<class T>
T & CircularQueue< T >::get ( int  position = 0  )  const [inline]

Returns a reference of an element in the queue from a specified position.

Parameters:
position The position of the returned element, counting from the head of the queue. The head has position 0.

Definition at line 100 of file CircularQueue.h.

References CircularQueue< T >::_size, CircularQueue< T >::current, and CircularQueue< T >::entry.

Referenced by AnalogDelayObject::advance(), and AnalogDelayObject::getAnalogOutput().

template<class T>
void CircularQueue< T >::put ( const T &  elem  )  [inline]

Puts new element at the tail of the queue.

This effectively drops one element from the head, since the queue is circular and fixed size.

Parameters:
elem reference to the element which copy is put in the queue.

Definition at line 142 of file CircularQueue.h.

References CircularQueue< T >::_size, CircularQueue< T >::current, and CircularQueue< T >::entry.

Referenced by AnalogDelayObject::advance().

template<class T>
void CircularQueue< T >::moveMark ( int  steps  )  [inline]

Moves the mark of the queue forward for specific number of steps.

Definition at line 132 of file CircularQueue.h.

References CircularQueue< T >::_size, and CircularQueue< T >::currentMark.

Referenced by AnalogDelayObject::advanceCycle(), and AnalogDelayObject::putNewCycleValues().

template<class T>
T & CircularQueue< T >::getFromMark ( int  position  )  const [inline]

Returns a reference of an element in the queue from a calculated position.

Parameters:
position The position of the wanted element, counting from the marked position.

Definition at line 123 of file CircularQueue.h.

References CircularQueue< T >::_size, CircularQueue< T >::currentMark, and CircularQueue< T >::entry.

Referenced by AnalogDelayObject::getCycledAnalogOutput().

template<class T>
void CircularQueue< T >::reset ( v  )  [inline]

template<class T>
void CircularQueue< T >::putArray ( double arr,
int  len 
) [inline]


Member Data Documentation

template<class T>
size_t CircularQueue< T >::_size [protected]

template<class T>
unsigned CircularQueue< T >::current [protected]

template<class T>
unsigned CircularQueue< T >::currentMark [protected]

template<class T>
T* CircularQueue< T >::entry [protected]


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

Generated on Wed Jul 9 16:34:47 2008 for PCSIM by  doxygen 1.5.5