summaryrefslogtreecommitdiffstats
path: root/trunk/source/FixAry.h
diff options
context:
space:
mode:
authorpeterb12 <peterb12@c06c8d41-db1a-0410-9941-cceddc491573>2005-07-21 02:34:44 +0000
committerpeterb12 <peterb12@c06c8d41-db1a-0410-9941-cceddc491573>2005-07-21 02:34:44 +0000
commit673bdae75485d14f759af597c3c62b99601f9a43 (patch)
tree368103f29fe0ce5dcf98060d9b5faa04590085fb /trunk/source/FixAry.h
parent7e900be770db24b0405fd2162491c405a425873e (diff)
downloadcrawl-ref-673bdae75485d14f759af597c3c62b99601f9a43.tar.gz
crawl-ref-673bdae75485d14f759af597c3c62b99601f9a43.zip
Initial revision
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'trunk/source/FixAry.h')
-rw-r--r--trunk/source/FixAry.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/trunk/source/FixAry.h b/trunk/source/FixAry.h
new file mode 100644
index 0000000000..58db5bb58d
--- /dev/null
+++ b/trunk/source/FixAry.h
@@ -0,0 +1,73 @@
+/*
+ * File: FixAry.h
+ * Summary: Fixed size 2D vector class that asserts if you do something bad.
+ * Written by: Jesse Jones
+ *
+ * Change History (most recent first):
+ *
+ * <1> 6/16/00 JDJ Created
+ */
+
+#ifndef FIXARY_H
+#define FIXARY_H
+
+#include "FixVec.h"
+
+
+// ==========================================================================
+// class FixedArray
+// ==========================================================================
+template <class TYPE, int WIDTH, int HEIGHT> class FixedArray {
+
+//-----------------------------------
+// Types
+//
+public:
+ typedef TYPE value_type;
+ typedef TYPE& reference;
+ typedef const TYPE& const_reference;
+ typedef TYPE* pointer;
+ typedef const TYPE* const_pointer;
+
+ typedef unsigned long size_type;
+ typedef long difference_type;
+
+ typedef FixedVector<TYPE, HEIGHT> Column; // operator[] needs to return one of these to avoid breaking client code (if inlining is on there won't be a speed hit)
+
+//-----------------------------------
+// Initialization/Destruction
+//
+public:
+ ~FixedArray() {}
+
+ FixedArray() {}
+
+private:
+ FixedArray(const FixedArray& rhs);
+
+ FixedArray& operator=(const FixedArray& rhs);
+
+//-----------------------------------
+// API
+//
+public:
+ // ----- Size -----
+ bool empty() const {return WIDTH == 0 || HEIGHT == 0;}
+ int size() const {return WIDTH*HEIGHT;}
+
+ int width() const {return WIDTH;}
+ int height() const {return HEIGHT;}
+
+ // ----- Access -----
+ Column& operator[](unsigned long index) {return mData[index];}
+ const Column& operator[](unsigned long index) const {return mData[index];}
+
+//-----------------------------------
+// Member Data
+//
+protected:
+ FixedVector<Column, WIDTH> mData;
+};
+
+
+#endif // FIXARY_H