--- /dev/null
+/* $Id$
+
+This file is part of NetVis
+Copyright @ 2008 Mikko Rasa, Mikkosoft Productions
+Distributed unter the GPL
+*/
+
+#ifndef RINGBUFFER_H_
+#define RINGBUFFER_H_
+
+#include <vector>
+
+template<typename T>
+class RingBuffer
+{
+private:
+ unsigned sz;
+ std::vector<T> data;
+ unsigned pos;
+
+public:
+ RingBuffer(unsigned s): sz(s), data(sz), pos(0) { }
+ void push(const T &v) { data[pos=(pos+1)%sz] = v; }
+ const T &get(unsigned i) const { return data[(pos+sz-i)%sz]; }
+ unsigned size() const { return sz; }
+};
+
+#endif