From 842b2c91c85eadf3e9a62d35f359bd7bc50f679e Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Sun, 15 Nov 2009 19:33:08 +0100 Subject: Rename fixary.h and fixvec.h. --- crawl-ref/source/dungeon.h | 4 +- crawl-ref/source/externs.h | 2 +- crawl-ref/source/files.h | 2 +- crawl-ref/source/fixary.h | 136 ----------------------------------------- crawl-ref/source/fixedarray.h | 136 +++++++++++++++++++++++++++++++++++++++++ crawl-ref/source/fixedvector.h | 121 ++++++++++++++++++++++++++++++++++++ crawl-ref/source/fixvec.h | 121 ------------------------------------ crawl-ref/source/maps.h | 2 +- crawl-ref/source/mon-grow.h | 2 +- crawl-ref/source/mon-place.h | 2 +- crawl-ref/source/ray.h | 2 +- crawl-ref/source/show.h | 2 +- crawl-ref/source/spl-book.h | 2 +- crawl-ref/source/tilesdl.h | 2 +- crawl-ref/source/transfor.h | 2 +- crawl-ref/source/travel.cc | 2 +- 16 files changed, 270 insertions(+), 270 deletions(-) delete mode 100644 crawl-ref/source/fixary.h create mode 100644 crawl-ref/source/fixedarray.h create mode 100644 crawl-ref/source/fixedvector.h delete mode 100644 crawl-ref/source/fixvec.h (limited to 'crawl-ref') diff --git a/crawl-ref/source/dungeon.h b/crawl-ref/source/dungeon.h index 793fccc2c8..b8cace2155 100644 --- a/crawl-ref/source/dungeon.h +++ b/crawl-ref/source/dungeon.h @@ -8,8 +8,8 @@ #ifndef DUNGEON_H #define DUNGEON_H -#include "fixvec.h" -#include "fixary.h" +#include "fixedvector.h" +#include "fixedarray.h" #include "externs.h" #include "terrain.h" #include "travel.h" diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index c53d9b8559..e7ec27bf64 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -20,7 +20,7 @@ #include "defines.h" #include "enum.h" -#include "fixary.h" +#include "fixedarray.h" #include "libutil.h" #include "mpr.h" #include "store.h" diff --git a/crawl-ref/source/files.h b/crawl-ref/source/files.h index 23cb9d3041..2854bfac74 100644 --- a/crawl-ref/source/files.h +++ b/crawl-ref/source/files.h @@ -9,7 +9,7 @@ #define FILES_H #include "externs.h" -#include "fixary.h" +#include "fixedarray.h" #include "player.h" #include #include diff --git a/crawl-ref/source/fixary.h b/crawl-ref/source/fixary.h deleted file mode 100644 index faf35b7c38..0000000000 --- a/crawl-ref/source/fixary.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * File: fixary.h - * Summary: Fixed size 2D vector class that asserts if you do something bad. - * Written by: Jesse Jones - */ - -#ifndef FIXARY_H -#define FIXARY_H - -#include "fixvec.h" - - -// ========================================================================== -// class FixedArray -// ========================================================================== -template 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; - - // operator[] should return one of these to avoid breaking - // client code (if inlining is on there won't be a speed hit) - typedef FixedVector Column; - -//----------------------------------- -// Initialization/Destruction -// -public: - ~FixedArray() {} - - FixedArray() {} - - FixedArray(TYPE def) - { - init(def); - } - -//----------------------------------- -// 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]; - } - - template TYPE& operator () (const Indexer &i) { - return mData[i.x][i.y]; - } - - template const TYPE& operator () (const Indexer &i) const { - return mData[i.x][i.y]; - } - - void init(const TYPE& def) { - for ( int i = 0; i < WIDTH; ++i ) - mData[i].init(def); - } - -protected: - FixedVector mData; -}; - -// A fixed array centered around the origin. -template class SquareArray { -//----------------------------------- -// 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; - -//----------------------------------- -// Initialization/Destruction -// -public: - ~SquareArray() {} - - SquareArray() {} - - SquareArray(TYPE def) - { - init(def); - } - -//----------------------------------- -// API -// -public: - // ----- Size ----- - bool empty() const { return data.empty(); } - int size() const { return data.size(); } - int width() const { return data.width(); } - int height() const { return data.height(); } - - // ----- Access ----- - template TYPE& operator () (const Indexer &i) { - return data[i.x+RADIUS][i.y+RADIUS]; - } - - template const TYPE& operator () (const Indexer &i) const { - return data[i.x+RADIUS][i.y+RADIUS]; - } - - void init(const TYPE& def) { - data.init(def); - } - -protected: - FixedArray data; -}; - -#endif // FIXARY_H diff --git a/crawl-ref/source/fixedarray.h b/crawl-ref/source/fixedarray.h new file mode 100644 index 0000000000..c1dabfd040 --- /dev/null +++ b/crawl-ref/source/fixedarray.h @@ -0,0 +1,136 @@ +/* + * File: fixedarray.h + * Summary: Fixed size 2D vector class that asserts if you do something bad. + * Written by: Jesse Jones + */ + +#ifndef FIXARY_H +#define FIXARY_H + +#include "fixedvector.h" + + +// ========================================================================== +// class FixedArray +// ========================================================================== +template 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; + + // operator[] should return one of these to avoid breaking + // client code (if inlining is on there won't be a speed hit) + typedef FixedVector Column; + +//----------------------------------- +// Initialization/Destruction +// +public: + ~FixedArray() {} + + FixedArray() {} + + FixedArray(TYPE def) + { + init(def); + } + +//----------------------------------- +// 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]; + } + + template TYPE& operator () (const Indexer &i) { + return mData[i.x][i.y]; + } + + template const TYPE& operator () (const Indexer &i) const { + return mData[i.x][i.y]; + } + + void init(const TYPE& def) { + for ( int i = 0; i < WIDTH; ++i ) + mData[i].init(def); + } + +protected: + FixedVector mData; +}; + +// A fixed array centered around the origin. +template class SquareArray { +//----------------------------------- +// 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; + +//----------------------------------- +// Initialization/Destruction +// +public: + ~SquareArray() {} + + SquareArray() {} + + SquareArray(TYPE def) + { + init(def); + } + +//----------------------------------- +// API +// +public: + // ----- Size ----- + bool empty() const { return data.empty(); } + int size() const { return data.size(); } + int width() const { return data.width(); } + int height() const { return data.height(); } + + // ----- Access ----- + template TYPE& operator () (const Indexer &i) { + return data[i.x+RADIUS][i.y+RADIUS]; + } + + template const TYPE& operator () (const Indexer &i) const { + return data[i.x+RADIUS][i.y+RADIUS]; + } + + void init(const TYPE& def) { + data.init(def); + } + +protected: + FixedArray data; +}; + +#endif // FIXARY_H diff --git a/crawl-ref/source/fixedvector.h b/crawl-ref/source/fixedvector.h new file mode 100644 index 0000000000..3afacd0898 --- /dev/null +++ b/crawl-ref/source/fixedvector.h @@ -0,0 +1,121 @@ +/* + * File: fixedvector.h + * Summary: Fixed size vector class that asserts if you do something bad. + * Written by: Jesse Jones + */ + +#ifndef FIXVEC_H +#define FIXVEC_H + +#include +#include + +#include "debug.h" +// ========================================================================== +// class FixedVector +// ========================================================================== + +template class FixedVector +{ + +//----------------------------------- +// 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 TYPE* iterator; + typedef const TYPE* const_iterator; + +//----------------------------------- +// Initialization/Destruction +// +public: + ~FixedVector() {} + + FixedVector() {} + + FixedVector(TYPE def) : mData() + { + init(def); + } + + FixedVector(TYPE value0, TYPE value1, ...); + // Allows for something resembling C array initialization, eg + // instead of "int a[3] = {0, 1, 2}" you'd use "FixedVector + // a(0, 1, 2)". Note that there must be SIZE arguments. + +//----------------------------------- +// API +// +public: + // ----- Size ----- + bool empty() const { return SIZE == 0; } + size_t size() const { return SIZE; } + + // ----- Access ----- + TYPE& operator[](unsigned long index) { + ASSERT(index < SIZE); + return mData[index]; + } + + const TYPE& operator[](unsigned long index) const { + ASSERT(index < SIZE); + return mData[index]; + } + + const TYPE* buffer() const { return mData; } + TYPE* buffer() { return mData; } + + // ----- Iterating ----- + iterator begin() { return mData; } + const_iterator begin() const { return mData; } + + iterator end() { return this->begin() + this->size(); } + const_iterator end() const { return this->begin() + this->size(); } + void init(const TYPE& def); + +//----------------------------------- +// Member Data +// +protected: + TYPE mData[SIZE]; +}; + + +// ========================================================================== +// Outlined Methods +// ========================================================================== +template +FixedVector::FixedVector(TYPE value0, TYPE value1, ...) +{ + mData[0] = value0; + mData[1] = value1; + + va_list ap; + va_start(ap, value1); // second argument is last fixed parameter + + for (int index = 2; index < SIZE; index++) + { + TYPE value = va_arg(ap, TYPE); + mData[index] = value; + } + + va_end(ap); +} + +template +void FixedVector::init(const TYPE& def) +{ + for (int i = 0; i < SIZE; ++i) + mData[i] = def; +} + +#endif // FIXVEC_H diff --git a/crawl-ref/source/fixvec.h b/crawl-ref/source/fixvec.h deleted file mode 100644 index 476eded773..0000000000 --- a/crawl-ref/source/fixvec.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * File: fixvec.h - * Summary: Fixed size vector class that asserts if you do something bad. - * Written by: Jesse Jones - */ - -#ifndef FIXVEC_H -#define FIXVEC_H - -#include -#include - -#include "debug.h" -// ========================================================================== -// class FixedVector -// ========================================================================== - -template class FixedVector -{ - -//----------------------------------- -// 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 TYPE* iterator; - typedef const TYPE* const_iterator; - -//----------------------------------- -// Initialization/Destruction -// -public: - ~FixedVector() {} - - FixedVector() {} - - FixedVector(TYPE def) : mData() - { - init(def); - } - - FixedVector(TYPE value0, TYPE value1, ...); - // Allows for something resembling C array initialization, eg - // instead of "int a[3] = {0, 1, 2}" you'd use "FixedVector - // a(0, 1, 2)". Note that there must be SIZE arguments. - -//----------------------------------- -// API -// -public: - // ----- Size ----- - bool empty() const { return SIZE == 0; } - size_t size() const { return SIZE; } - - // ----- Access ----- - TYPE& operator[](unsigned long index) { - ASSERT(index < SIZE); - return mData[index]; - } - - const TYPE& operator[](unsigned long index) const { - ASSERT(index < SIZE); - return mData[index]; - } - - const TYPE* buffer() const { return mData; } - TYPE* buffer() { return mData; } - - // ----- Iterating ----- - iterator begin() { return mData; } - const_iterator begin() const { return mData; } - - iterator end() { return this->begin() + this->size(); } - const_iterator end() const { return this->begin() + this->size(); } - void init(const TYPE& def); - -//----------------------------------- -// Member Data -// -protected: - TYPE mData[SIZE]; -}; - - -// ========================================================================== -// Outlined Methods -// ========================================================================== -template -FixedVector::FixedVector(TYPE value0, TYPE value1, ...) -{ - mData[0] = value0; - mData[1] = value1; - - va_list ap; - va_start(ap, value1); // second argument is last fixed parameter - - for (int index = 2; index < SIZE; index++) - { - TYPE value = va_arg(ap, TYPE); - mData[index] = value; - } - - va_end(ap); -} - -template -void FixedVector::init(const TYPE& def) -{ - for (int i = 0; i < SIZE; ++i) - mData[i] = def; -} - -#endif // FIXVEC_H diff --git a/crawl-ref/source/maps.h b/crawl-ref/source/maps.h index afaac0695e..77a86b941a 100644 --- a/crawl-ref/source/maps.h +++ b/crawl-ref/source/maps.h @@ -9,7 +9,7 @@ #define MAPS_H #include "dlua.h" -#include "fixvec.h" +#include "fixedvector.h" #include "dungeon.h" #include diff --git a/crawl-ref/source/mon-grow.h b/crawl-ref/source/mon-grow.h index 5201421019..0f60bff722 100644 --- a/crawl-ref/source/mon-grow.h +++ b/crawl-ref/source/mon-grow.h @@ -7,7 +7,7 @@ #ifndef __MGROW_H__ #define __MGROW_H__ -#include "fixvec.h" +#include "fixedvector.h" // Monster level-up data. diff --git a/crawl-ref/source/mon-place.h b/crawl-ref/source/mon-place.h index a0211692bb..533f0943dc 100644 --- a/crawl-ref/source/mon-place.h +++ b/crawl-ref/source/mon-place.h @@ -11,7 +11,7 @@ #include "coord.h" #include "enum.h" #include "dungeon.h" -#include "fixvec.h" +#include "fixedvector.h" enum band_type { diff --git a/crawl-ref/source/ray.h b/crawl-ref/source/ray.h index adca5003dd..242c8f76f2 100644 --- a/crawl-ref/source/ray.h +++ b/crawl-ref/source/ray.h @@ -6,7 +6,7 @@ #ifndef RAY_H #define RAY_H -#include "fixary.h" +#include "fixedarray.h" #include "geom2d.h" typedef SquareArray reflect_grid; diff --git a/crawl-ref/source/show.h b/crawl-ref/source/show.h index a7b31033b7..f21e24ece8 100644 --- a/crawl-ref/source/show.h +++ b/crawl-ref/source/show.h @@ -1,7 +1,7 @@ #ifndef SHOW_H #define SHOW_H -#include "fixary.h" +#include "fixedarray.h" enum show_item_type { diff --git a/crawl-ref/source/spl-book.h b/crawl-ref/source/spl-book.h index d4ab7630f3..908f42df31 100644 --- a/crawl-ref/source/spl-book.h +++ b/crawl-ref/source/spl-book.h @@ -9,7 +9,7 @@ #define SPL_BOOK_H #include "externs.h" -#include "fixvec.h" +#include "fixedvector.h" #define SPELLBOOK_SIZE 8 diff --git a/crawl-ref/source/tilesdl.h b/crawl-ref/source/tilesdl.h index e7cede1863..f20ca14813 100644 --- a/crawl-ref/source/tilesdl.h +++ b/crawl-ref/source/tilesdl.h @@ -10,7 +10,7 @@ #include "debug.h" #include "externs.h" -#include "fixvec.h" +#include "fixedvector.h" #include "tilereg.h" // This struct defines all of the state that any particular rendering needs. diff --git a/crawl-ref/source/transfor.h b/crawl-ref/source/transfor.h index 8d9bc85285..52cc7e9391 100644 --- a/crawl-ref/source/transfor.h +++ b/crawl-ref/source/transfor.h @@ -10,7 +10,7 @@ #include -#include "fixvec.h" +#include "fixedvector.h" #include "enum.h" enum transformation_type diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 060191bb50..18ab3969be 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -12,7 +12,7 @@ #include "coord.h" #include "coordit.h" #include "files.h" -#include "fixary.h" +#include "fixedarray.h" #include "branch.h" #include "command.h" #include "cio.h" -- cgit v1.2.3-54-g00ecf