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 remove (int id)
 Remove item with id. More...
 
void clear ()
 Resets the buffer to an empty buffer with a 0 index. More...
 
SYS_NO_DISCARD_RESULT T popFirst ()
 
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
 
void insert (int id, const T &data)
 
void insert (int id, T &&data)
 
int push (const T &data)
 
int push (T &&data)
 

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 25 of file UT_RingBuffer.h.

Constructor & Destructor Documentation

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

Definition at line 21 of file UT_RingBuffer.C.

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

Definition at line 27 of file UT_RingBuffer.C.

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

Definition at line 34 of file UT_RingBuffer.C.

Member Function Documentation

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

Definition at line 95 of file UT_RingBuffer.h.

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

Definition at line 96 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 76 of file UT_RingBuffer.C.

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

Definition at line 107 of file UT_RingBuffer.C.

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

Definition at line 77 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 93 of file UT_RingBuffer.h.

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

Definition at line 94 of file UT_RingBuffer.h.

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

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 38 of file UT_RingBuffer.h.

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

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 40 of file UT_RingBuffer.h.

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

Definition at line 83 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 98 of file UT_RingBuffer.C.

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

Definition at line 78 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 145 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 87 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 156 of file UT_RingBuffer.h.

template<typename T>
SYS_NO_DISCARD_RESULT 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 53 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 63 of file UT_RingBuffer.h.

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

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

Definition at line 64 of file UT_RingBuffer.h.

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

Remove item with id.

Definition at line 61 of file UT_RingBuffer.C.

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

Definition at line 76 of file UT_RingBuffer.h.


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