18#ifndef __MEMORY_ALLOCATORS_H__
19#define __MEMORY_ALLOCATORS_H__
23template <
class T> T** AllocateMatrix(
int rows,
int cols);
24template <
class T> T** AllocateMatrix(
int rows,
int cols, T value);
25template <
class T>
void FreeMatrix(T ** & matrix,
int rows);
27char ** AllocateCharMatrix(
int rows,
int cols);
28void FreeCharMatrix(
char ** & matrix,
int rows);
30float ** AllocateFloatMatrix(
int rows,
int cols);
31void FreeFloatMatrix(
float ** & matrix,
int rows);
33double ** AllocateDoubleMatrix(
int rows,
int cols);
34void FreeDoubleMatrix(
double ** & matrix,
int rows);
36int ** AllocateIntMatrix(
int rows,
int cols);
37void FreeIntMatrix(
int ** & matrix,
int rows);
39short ** AllocateShortMatrix(
int rows,
int cols);
40void FreeShortMatrix(
short ** & matrix,
int rows);
42char *** AllocateCharCube(
int n,
int rows,
int cols);
43void FreeCharCube(
char *** & matrix,
int n,
int rows);
49template <
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)
76template <
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++)
88template <
class T>
void FreeMatrix(T ** & matrix,
int rows)
93 for (
int i = 0; i < rows; i++)