Edinburgh Speech Tools  2.1-release
EST_TBuffer< T > Class Template Reference

Extending buffer class. More...

#include <include/EST_TBuffer.h>

Public Member Functions

 EST_TBuffer (unsigned int size=TBUFFER_DEFAULT_SIZE, int step=TBUFFER_DEFAULT_STEP)
 
 ~EST_TBuffer (void)
 Destructor. Places the memory in EST_old_buffers[] for re-use if there is room. More...
 
unsigned int length (void) const
 Current available space. More...
 
void set (const T &set_to, int howmany=-1)
 Set to the given value. By default sets all values. More...
 
Methods to make sure there is enough space.
void ensure (unsigned int req_size)
 Extend if needed, copying existing data. More...
 
void ensure (unsigned int req_size, bool copy)
 Make sure there is enough space, copying if requested. More...
 
void ensure (unsigned int req_size, const T &set_to, int howmany=-1)
 Make sure there is enough space, setting to a known value. More...
 
Access to the memory itself.
T * b (void)
 Simple access as a pointer. More...
 
const T * b (void) const
 Read-only access when the EST_TBuffer is a constant. More...
 
const T & operator() (unsigned int i) const
 operator () is simple access More...
 
T & operator[] (unsigned int i)
 
const T & operator[] (unsigned int i) const
 

Detailed Description

template<class T>
class EST_TBuffer< T >

Extending buffer class.

This class provides the convenience of arrays which change in size at run time rather more efficiently than the full EST_TVector class would.

Buffers can only be expanded and when a buffer is no longer needed (i.e. when the variable goes out of scope) the memory is not deleted, rather it is saved for re-use as a new buffer.

A typical use would be a buffer to hold a windowed section of a signal inside a signal processing loop where the size of the window changes from iteration to iteration.

See also
EST_TBuffer.h, Associated definitions.
EST_TVector, class to use for more general uses.
lpc_analyse, example of use.

Definition at line 86 of file EST_TBuffer.h.

Constructor & Destructor Documentation

template<class T >
EST_TBuffer< T >::EST_TBuffer ( unsigned int  size = TBUFFER_DEFAULT_SIZE,
int  step = TBUFFER_DEFAULT_STEP 
)

Create with size and increment. Increment can be negative for percentage growth.

Tries to use a buffer from EST_old_buffers[] if there is one which is suitable

See also
EST_old_buffers

Definition at line 49 of file EST_TBuffer.cc.

template<class T >
EST_TBuffer< T >::~EST_TBuffer ( void  )

Destructor. Places the memory in EST_old_buffers[] for re-use if there is room.

Definition at line 56 of file EST_TBuffer.cc.

Member Function Documentation

template<class T>
unsigned int EST_TBuffer< T >::length ( void  ) const
inline

Current available space.

Definition at line 119 of file EST_TBuffer.h.

template<class T >
void EST_TBuffer< T >::set ( const T &  set_to,
int  howmany = -1 
)

Set to the given value. By default sets all values.

Definition at line 149 of file EST_TBuffer.cc.

template<class T>
void EST_TBuffer< T >::ensure ( unsigned int  req_size)
inline

Extend if needed, copying existing data.

Definition at line 128 of file EST_TBuffer.h.

template<class T>
void EST_TBuffer< T >::ensure ( unsigned int  req_size,
bool  copy 
)
inline

Make sure there is enough space, copying if requested.

Definition at line 132 of file EST_TBuffer.h.

template<class T>
void EST_TBuffer< T >::ensure ( unsigned int  req_size,
const T &  set_to,
int  howmany = -1 
)
inline

Make sure there is enough space, setting to a known value.

Definition at line 136 of file EST_TBuffer.h.

template<class T>
T* EST_TBuffer< T >::b ( void  )
inline

Simple access as a pointer.

Definition at line 144 of file EST_TBuffer.h.

template<class T>
const T* EST_TBuffer< T >::b ( void  ) const
inline

Read-only access when the EST_TBuffer is a constant.

Definition at line 146 of file EST_TBuffer.h.

template<class T>
const T& EST_TBuffer< T >::operator() ( unsigned int  i) const
inline

operator () is simple access

Definition at line 149 of file EST_TBuffer.h.

template<class T>
T& EST_TBuffer< T >::operator[] ( unsigned int  i)
inline

Definition at line 151 of file EST_TBuffer.h.

template<class T>
const T& EST_TBuffer< T >::operator[] ( unsigned int  i) const
inline

Definition at line 152 of file EST_TBuffer.h.


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