00001 #ifndef _CIRCLE_BUFF_H_
00002 #define _CIRCLE_BUFF_H_
00003
00004 template <class T, int S> class CircleBuff
00005 {
00006 public:
00007
00008 CircleBuff() {
00009 f=l=in=0;
00010 };
00011
00012 int entries() { return in; };
00013 void clear() { f=l=in=0; };
00014
00015 void add(T* a) {
00016 return;
00017
00018 in++;
00019 if(in > S) in=S;
00020
00021 store[l++] = *a;
00022 if(l >= S) l=0;
00023
00024 if(l == f) {
00025 f = l+1;
00026 if(f >= S) f=0;
00027 }
00028 }
00029
00030
00031 T* element(int i) {
00032 return NULL;
00033
00034 if(i >= in) return NULL;
00035 int x = (f+i) % S;
00036 return &store[x];
00037 };
00038
00039 private:
00040 T store[S];
00041 int f, l, in;
00042 };
00043
00044 #endif