You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3dpcp/.svn/pristine/c9/c9dc07e5a13261c60d6b05d52e4...

46 lines
1.3 KiB
Plaintext

template <class T>
void CSystem<T>::allocate (unsigned int unRows, unsigned int unCols, T** &aatArray)
{
aatArray = new T*[unRows];
aatArray[0] = new T[unRows*unCols];
for (unsigned int unRow = 1; unRow < unRows; unRow++)
{
aatArray[unRow] = &aatArray[0][unCols*unRow];
}
}
template <class T>
void CSystem<T>::deallocate (T**& aatArray)
{
delete[] aatArray[0];
delete[] aatArray;
aatArray = 0;
}
template <class T>
void CSystem<T>::allocate (unsigned int unRows, unsigned int unCols, unsigned int unSlices, T*** &aaatArray)
{
aaatArray = new T**[unRows];
aaatArray[0] = new T*[unRows*unCols];
aaatArray[0][0] = new T[unRows*unCols*unSlices];
for (unsigned int unRow = 0; unRow < unRows; unRow++)
{
aaatArray[unRow] = &aaatArray[0][unRow*unCols];
for (unsigned int unCol = 0; unCol < unCols; unCol++)
{
aaatArray[unRow][unCol] =
&aaatArray[0][0][unRow*(unCols*unSlices)+unCol*unSlices];
}
}
}
template <class T>
void CSystem<T>::deallocate (T***& aaatArray)
{
// fairAssert(aaatArray != NULL, "Assertion while trying to deallocate null pointer reference");
delete[] aaatArray[0][0];
delete[] aaatArray[0];
delete[] aaatArray;
aaatArray = 0;
}