cb.h
上传用户:lqyjxl
上传日期:2015-08-21
资源大小:14k
文件大小:1k
- // file: cb.h
//
// this file defines a circular buffer class
//
// make sure definitions are only made once
//
#ifndef __CB
#define __CB
class Circular_buffer {
//---------------------------------------------------------------------------
//
// protected data
//
//---------------------------------------------------------------------------
protected:
// data information
//
int idx_d;
int size_d;
double *buf_d;
//---------------------------------------------------------------------------
//
// public methods
//
//---------------------------------------------------------------------------
public:
// constructors/destructors
//
Circular_buffer();
~Circular_buffer();
// allocation
//
void allocate_cc(int num_elements);
// indexing methods
//
int add_cc(double new_value);
// overloaded operators
//
double operator() (int index);
operator float() {return (float)buf_d[idx_d];}
double & operator= ( double value)
- {
add_cc(value);
return buf_d[idx_d];
}
//---------------------------------------------------------------------------
//
// private methods
//
//---------------------------------------------------------------------------
private:
// none
};
//
// end of include file
#endif