00001 00036 #ifndef ABA_RING_H 00037 #define ABA_RING_H 00038 00039 #include "abacus/array.h" 00040 00041 #ifdef ABACUS_NEW_TEMPLATE_SYNTAX 00042 template <class Type> 00043 class ABA_RING; 00044 00045 template <class Type> 00046 ostream &operator<< (ostream &out, const ABA_RING<Type> &ring); 00047 #endif 00048 00049 template <class Type> class ABA_RING : public ABA_ABACUSROOT { 00050 public: 00051 00057 ABA_RING(ABA_GLOBAL *glob, int size); 00058 00060 virtual ~ABA_RING(); 00061 #ifdef ABACUS_NEW_TEMPLATE_SYNTAX 00062 00072 friend ostream &operator<< <> (ostream &, const ABA_RING<Type> &); 00073 #else 00074 00084 friend ostream &operator<< (ostream &out, const ABA_RING<Type> &ring); 00085 #endif 00086 00092 Type& operator[](int i); 00093 00097 const Type& operator[](int i) const; 00098 00106 void insert(Type elem); 00107 00110 void clear(); 00111 00114 int size() const; 00115 00118 int number() const; 00119 00123 Type oldest() const; 00124 00128 int oldestIndex() const; 00129 00133 Type newest() const; 00134 00138 int newestIndex() const; 00139 00153 int previous(int i, Type &p) const; 00154 00158 bool empty() const; 00159 00163 bool filled() const; 00164 00171 void realloc(int newSize); 00172 00173 private: 00174 00177 ABA_GLOBAL *glob_; 00178 00181 ABA_ARRAY<Type> ring_; 00182 00185 int head_; 00186 00189 bool filled_; 00190 }; 00191 00192 #include "abacus/ring.inc" 00193 00194 #endif // ABA_RING_H 00195