diff options
author | nlanza <nlanza@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-08-13 02:19:00 +0000 |
---|---|---|
committer | nlanza <nlanza@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-08-13 02:19:00 +0000 |
commit | aa88fdd8c6ad2da5eb5bd933e2d53d56cd8c176f (patch) | |
tree | d0551b96eaebb5b55694579fb8dae4abc7a38407 /crawl-ref/source/FixAry.h | |
parent | 2b32f164e6ca1c4b3d587789f6cf46f46fe02fe8 (diff) | |
download | crawl-ref-aa88fdd8c6ad2da5eb5bd933e2d53d56cd8c176f.tar.gz crawl-ref-aa88fdd8c6ad2da5eb5bd933e2d53d56cd8c176f.zip |
Clean up a mistake in the SVN import.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/FixAry.h')
-rw-r--r-- | crawl-ref/source/FixAry.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/crawl-ref/source/FixAry.h b/crawl-ref/source/FixAry.h new file mode 100644 index 0000000000..99f802e2f3 --- /dev/null +++ b/crawl-ref/source/FixAry.h @@ -0,0 +1,68 @@ +/* + * 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() {} + +//----------------------------------- +// 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 |