summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-06-17 01:41:44 +0200
committerTreeki <treeki@gmail.com>2011-06-17 01:41:44 +0200
commit1a0290bfce4c9aa473abc9d143c308170988c402 (patch)
treece349fbd2d70d73e4de505db88cf176423194953 /include
parentd6011147ab248b0290982c6ddebada8221209255 (diff)
downloadkamek-1a0290bfce4c9aa473abc9d143c308170988c402.tar.gz
kamek-1a0290bfce4c9aa473abc9d143c308170988c402.zip
added mDynArray_c class .. should probably be mVarArray_c though
Diffstat (limited to 'include')
-rw-r--r--include/m_dynarray.h32
1 files changed, 32 insertions, 0 deletions
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 <typename TValue, int TMaxSize>
+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); }
+};
+
+