#include <Array2d.h>
Public Member Functions | |
| BengArray2D (unsigned int xsize, unsigned int ysize) | |
| ~BengArray2D (void) | |
| void | getSize (unsigned int &xOut, unsigned int &yOut) |
| Returns the dimensions of the array in xOut and yOut. | |
| void | setElement (unsigned int xIn, unsigned int yIn, T data) |
| T | getElement (unsigned int xIn, unsigned int yIn) |
| T ** | getRawData (void) |
Protected Attributes | |
| unsigned int | sizeX |
| The number of columns the array takes up. | |
| unsigned int | sizeY |
| The number of rows the array takes up. | |
| T * | tileMap |
| Contains the actual data used by the array, in contiguous space. | |
| T ** | tileRows |
| Pointers to each row. This is returned on a call to getRawData(). | |
BengArray<int> *myArray = new BengArray2D<int>(32, 32);
myArrayData = myArray->getRawData();
myArrayData[2][3] = FOO_BAR;
delete myArray;
| BengArray2D< T >::BengArray2D | ( | unsigned int | xsize, | |
| unsigned int | ysize | |||
| ) | [inline] |
Creates a two-dimensional array and allocates the space for it so that it can be used like a C array. Like a traditional array, all the contents will be initialized to zero.
| BengArray2D< T >::~BengArray2D | ( | void | ) | [inline] |
Destroys the 2D array, freeing the allocated space. It does not, however, free up any objects referenced by pointers in the array if the array is typed as a pointer. You will need to do this manually.
| T BengArray2D< T >::getElement | ( | unsigned int | xIn, | |
| unsigned int | yIn | |||
| ) | [inline] |
Retrieves the value of one cell in the array, given coordinates xIn and yIn. This function will perform bounds checking. If the given coordinates are not in the array, the function does nothing.
| T** BengArray2D< T >::getRawData | ( | void | ) | [inline] |
Returns a T** pointer to the raw data of the array so that you can use it unchecked just like a C array:
myArrayData = myArray->getRawData();
myArrayData[2][3] = FOO_BAR;
| void BengArray2D< T >::getSize | ( | unsigned int & | xOut, | |
| unsigned int & | yOut | |||
| ) | [inline] |
Returns the dimensions of the array in xOut and yOut.
| void BengArray2D< T >::setElement | ( | unsigned int | xIn, | |
| unsigned int | yIn, | |||
| T | data | |||
| ) | [inline] |
Changes the value of one cell in the array, given coordinates xIn and yIn, and the data to replace the cell with. This function will perform bounds checking. If the given coordinates are not in the array, the function does nothing.
unsigned int BengArray2D< T >::sizeX [protected] |
The number of columns the array takes up.
unsigned int BengArray2D< T >::sizeY [protected] |
The number of rows the array takes up.
T* BengArray2D< T >::tileMap [protected] |
Contains the actual data used by the array, in contiguous space.
T** BengArray2D< T >::tileRows [protected] |
Pointers to each row. This is returned on a call to getRawData().
1.5.8