18 #ifndef __MEMORY_ALLOCATORS_H__ 19 #define __MEMORY_ALLOCATORS_H__ 23 template <
class T> T** AllocateMatrix(
int rows,
int cols);
24 template <
class T> T** AllocateMatrix(
int rows,
int cols, T value);
25 template <
class T>
void FreeMatrix(T ** & matrix,
int rows);
27 char ** AllocateCharMatrix(
int rows,
int cols);
28 void FreeCharMatrix(
char ** & matrix,
int rows);
30 float ** AllocateFloatMatrix(
int rows,
int cols);
31 void FreeFloatMatrix(
float ** & matrix,
int rows);
33 double ** AllocateDoubleMatrix(
int rows,
int cols);
34 void FreeDoubleMatrix(
double ** & matrix,
int rows);
36 int ** AllocateIntMatrix(
int rows,
int cols);
37 void FreeIntMatrix(
int ** & matrix,
int rows);
39 short ** AllocateShortMatrix(
int rows,
int cols);
40 void FreeShortMatrix(
short ** & matrix,
int rows);
42 char *** AllocateCharCube(
int n,
int rows,
int cols);
43 void FreeCharCube(
char *** & matrix,
int n,
int rows);
49 template <
class T> T** AllocateMatrix(
int rows,
int cols)
51 T ** matrix =
new T * [rows];
57 for (
int i = 0; i < rows; i++)
59 matrix[i] =
new T [cols];
62 if (matrix[i] == NULL)
76 template <
class T> T** AllocateMatrix(
int rows,
int cols, T value)
78 T ** matrix = AllocateMatrix<T>(rows, cols);
81 for (
int i = 0; i < rows; i++)
82 for (
int j = 0; j < cols; j++)
88 template <
class T>
void FreeMatrix(T ** & matrix,
int rows)
93 for (
int i = 0; i < rows; i++)