From 1a0290bfce4c9aa473abc9d143c308170988c402 Mon Sep 17 00:00:00 2001 From: Treeki Date: Fri, 17 Jun 2011 01:41:44 +0200 Subject: added mDynArray_c class .. should probably be mVarArray_c though --- include/m_dynarray.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 include/m_dynarray.h (limited to 'include') diff --git a/include/m_dynarray.h b/include/m_dynarray.h new file mode 100644 index 0000000..6cb4209 --- /dev/null +++ b/include/m_dynarray.h @@ -0,0 +1,32 @@ +template +class mDynArray_c { + int currentSize; + TValue buffer[TMaxSize]; + + public: + mDynArray_c() { currentSize = 0; } + + int count() { return currentSize; } + int max() { return TMaxSize; } + + TValue& get(int index) const { return buffer[index]; } + void set(int index, TValue &newValue) { buffer[index] = newValue; } + + void append(TValue &newValue) { + set(currentSize, newValue); + currentSize += 1; + } + + TValue &pop() { + currentSize -= 1; + return get(currentSize - 1); + } + + TValue &first() const { return get(0); } + TValue &last() const { return get(currentSize - 1); } + + bool empty() const { return (currentSize == 0); } + bool full() const { return (currentSize == TMaxSize); } +}; + + -- cgit v1.2.3