An implementation of a circular array allowing direct write and read.

Revision:
0:28766f5a758e
Child:
1:5036a532fe62
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CircularArray.h	Tue Feb 11 18:41:26 2014 +0000
@@ -0,0 +1,30 @@
+
+#ifndef _CIRCULAR_ARRAY_H_
+#define _CIRCULAR_ARRAY_H_
+
+template<typename T> class CircularArray
+{
+    private:
+    unsigned int m_capacity;
+    volatile unsigned int w;
+    volatile unsigned int r;
+    volatile bool m_full;
+    volatile bool m_empty;
+    volatile T * data;
+    
+    public:
+        CircularArray(unsigned int capacity);
+        ~CircularArray();    
+        T * getWritePointer();
+        T * getReadPointer(T * buffer=0,unsigned int num=0);
+        void writeElements(unsigned int num);
+        void readElements(unsigned int num);
+        unsigned int fillCapacity();
+        unsigned int freeSpace();
+        unsigned int size();
+        unsigned int readable();
+        bool full();
+        bool empty();
+};
+
+#endif
\ No newline at end of file