summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/fixary.h50
-rw-r--r--crawl-ref/source/mapdef.h2
-rw-r--r--crawl-ref/source/matrix.h59
3 files changed, 60 insertions, 51 deletions
diff --git a/crawl-ref/source/fixary.h b/crawl-ref/source/fixary.h
index 8743e4573a..faf35b7c38 100644
--- a/crawl-ref/source/fixary.h
+++ b/crawl-ref/source/fixary.h
@@ -78,56 +78,6 @@ protected:
FixedVector<Column, WIDTH> mData;
};
-template <typename Z>
-class Matrix {
-public:
- Matrix(int width, int height, const Z &initial);
- Matrix(int width, int height);
- ~Matrix();
-
- void init(const Z &initial);
- Z &operator () (int x, int y)
- {
- return data[x + y * width];
- }
- const Z &operator () (int x, int y) const
- {
- return data[x + y * width];
- }
-
-private:
- Z *data;
- int width, height, size;
-};
-
-template <typename Z>
-Matrix<Z>::Matrix(int _width, int _height, const Z &initial)
- : data(NULL), width(_width), height(_height), size(_width * _height)
-{
- data = new Z [ size ];
- init(initial);
-}
-
-template <typename Z>
-Matrix<Z>::Matrix(int _width, int _height)
- : data(NULL), width(_width), height(_height), size(_width * _height)
-{
- data = new Z [ size ];
-}
-
-template <typename Z>
-Matrix<Z>::~Matrix()
-{
- delete [] data;
-}
-
-template <typename Z>
-void Matrix<Z>::init(const Z &initial)
-{
- for (int i = 0; i < size; ++i)
- data[i] = initial;
-}
-
// A fixed array centered around the origin.
template <class TYPE, int RADIUS> class SquareArray {
//-----------------------------------
diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h
index c70c16cece..b131cd0f8f 100644
--- a/crawl-ref/source/mapdef.h
+++ b/crawl-ref/source/mapdef.h
@@ -19,7 +19,7 @@
#include "dlua.h"
#include "enum.h"
#include "externs.h"
-#include "fixary.h"
+#include "matrix.h"
#include "fprop.h"
#include "makeitem.h"
#include "stuff.h"
diff --git a/crawl-ref/source/matrix.h b/crawl-ref/source/matrix.h
new file mode 100644
index 0000000000..520711ca88
--- /dev/null
+++ b/crawl-ref/source/matrix.h
@@ -0,0 +1,59 @@
+/*
+ * File: matrix.h
+ * Summary: Two-dimensional array class.
+ */
+
+#ifndef MATRIX_H
+#define MATRIX_H
+
+template <typename Z>
+class Matrix {
+public:
+ Matrix(int width, int height, const Z &initial);
+ Matrix(int width, int height);
+ ~Matrix();
+
+ void init(const Z &initial);
+ Z &operator () (int x, int y)
+ {
+ return data[x + y * width];
+ }
+ const Z &operator () (int x, int y) const
+ {
+ return data[x + y * width];
+ }
+
+private:
+ Z *data;
+ int width, height, size;
+};
+
+template <typename Z>
+Matrix<Z>::Matrix(int _width, int _height, const Z &initial)
+ : data(NULL), width(_width), height(_height), size(_width * _height)
+{
+ data = new Z [ size ];
+ init(initial);
+}
+
+template <typename Z>
+Matrix<Z>::Matrix(int _width, int _height)
+ : data(NULL), width(_width), height(_height), size(_width * _height)
+{
+ data = new Z [ size ];
+}
+
+template <typename Z>
+Matrix<Z>::~Matrix()
+{
+ delete [] data;
+}
+
+template <typename Z>
+void Matrix<Z>::init(const Z &initial)
+{
+ for (int i = 0; i < size; ++i)
+ data[i] = initial;
+}
+
+#endif // MATRIX_H