HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_RingBuffer< T > Class Template Reference

#include <UT_RingBuffer.h>

Public Member Functions

 UT_RingBuffer ()
 
 UT_RingBuffer (int capacity)
 
 ~UT_RingBuffer ()
 
void insert (int id, const T &data)
 
void remove (int id)
 
void clear ()
 Resets the buffer to an empty buffer with a 0 index. More...
 
T popFirst ()
 
int push (const T &data)
 
void pop ()
 Pop a single element from the start of the buffer. More...
 
void popBack ()
 Pop a single element from the back of the buffer. More...
 
void pop (int number)
 Pop the next "number" elements from the buffer. More...
 
int size () const
 
int entries () const
 
int peakUsage () const
 
T operator[] (int id) const
 
const Toperator() (int id) const
 
const Tfront () const
 
int frontId () const
 
const Tback () const
 
int backId () const
 
void display () const
 

Detailed Description

template<typename T>
class UT_RingBuffer< T >

A UT_RingBuffer is an indexable queue. The buffer uses indices that represent the insertion order of items in the buffer. The buffer may contain "holes", which have no associated data but still have an order number.

Definition at line 22 of file UT_RingBuffer.h.

Constructor & Destructor Documentation

template<typename T >
UT_RingBuffer< T >::UT_RingBuffer ( )

Definition at line 20 of file UT_RingBuffer.C.

template<typename T >
UT_RingBuffer< T >::UT_RingBuffer ( int  capacity)

Definition at line 26 of file UT_RingBuffer.C.

template<typename T >
UT_RingBuffer< T >::~UT_RingBuffer ( )

Definition at line 33 of file UT_RingBuffer.C.

Member Function Documentation

template<typename T>
const T& UT_RingBuffer< T >::back ( void  ) const
inline

Definition at line 78 of file UT_RingBuffer.h.

template<typename T>
int UT_RingBuffer< T >::backId ( ) const
inline

Definition at line 79 of file UT_RingBuffer.h.

template<typename T >
void UT_RingBuffer< T >::clear ( void  )

Resets the buffer to an empty buffer with a 0 index.

Definition at line 74 of file UT_RingBuffer.C.

template<typename T >
void UT_RingBuffer< T >::display ( ) const

Definition at line 105 of file UT_RingBuffer.C.

template<typename T>
int UT_RingBuffer< T >::entries ( void  ) const
inline

Definition at line 60 of file UT_RingBuffer.h.

template<typename T>
const T& UT_RingBuffer< T >::front ( void  ) const
inline

In order to iterate over the contents of the ring buffer for (i = rbuf.frontId(); i <= rbuf.backId(); i++) element = rbuf(i); The backId is inclusive!!! There shouldn't be holes in the array.

Definition at line 76 of file UT_RingBuffer.h.

template<typename T>
int UT_RingBuffer< T >::frontId ( ) const
inline

Definition at line 77 of file UT_RingBuffer.h.

template<typename T>
void UT_RingBuffer< T >::insert ( int  id,
const T data 
)

Null-padded insertion. If the id of the incoming object is greater than the next order number that would be assigned by push(), holes are created in the buffer.

Definition at line 39 of file UT_RingBuffer.C.

template<typename T>
const T& UT_RingBuffer< T >::operator() ( int  id) const
inline

Definition at line 66 of file UT_RingBuffer.h.

template<typename T >
T UT_RingBuffer< T >::operator[] ( int  id) const

operator [] is the bounds checked version of the operator. The id is the order number of the object being indexed.

Definition at line 96 of file UT_RingBuffer.C.

template<typename T>
int UT_RingBuffer< T >::peakUsage ( ) const
inline

Definition at line 61 of file UT_RingBuffer.h.

template<typename T >
void UT_RingBuffer< T >::pop ( )
inline

Pop a single element from the start of the buffer.

Definition at line 122 of file UT_RingBuffer.h.

template<typename T >
void UT_RingBuffer< T >::pop ( int  number)

Pop the next "number" elements from the buffer.

Definition at line 85 of file UT_RingBuffer.C.

template<typename T >
void UT_RingBuffer< T >::popBack ( )
inline

Pop a single element from the back of the buffer.

Definition at line 133 of file UT_RingBuffer.h.

template<typename T>
T UT_RingBuffer< T >::popFirst ( )
inline

Pop the first element off the head of the list, moving the first entry to the next element.

Definition at line 39 of file UT_RingBuffer.h.

template<typename T>
int UT_RingBuffer< T >::push ( const T data)
inline

Insert the data into the buffer, and return the order number that it is assigned.

Definition at line 109 of file UT_RingBuffer.h.

template<typename T >
void UT_RingBuffer< T >::remove ( int  id)

Definition at line 59 of file UT_RingBuffer.C.

template<typename T>
int UT_RingBuffer< T >::size ( void  ) const
inline

Definition at line 59 of file UT_RingBuffer.h.


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