1 /*****************************************************************************
5 ** Purpose: 2-dimension array classes
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: June 2000
9 ** This is part of the CTSim program
10 ** Copyright (c) 1983-2009 Kevin Rosenberg
12 ** This program is free software; you can redistribute it and/or modify
13 ** it under the terms of the GNU General Public License (version 2) as
14 ** published by the Free Software Foundation.
16 ** This program is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ** GNU General Public License for more details.
21 ** You should have received a copy of the GNU General Public License
22 ** along with this program; if not, write to the Free Software
23 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ******************************************************************************/
29 #include "ctsupport.h"
35 Array2d (unsigned int x, unsigned int y)
36 : m_nx(x), m_ny(y), array_data(0)
42 : m_nx(0), m_ny(0), array_data(0)
50 void initSetSize (unsigned int x, unsigned int y)
59 { return array_data; }
61 T* getColumn (unsigned int x) const
62 { return (array_data ? array_data[x] : NULL); }
64 T getPoint (unsigned int x, unsigned int y) const
65 { return (array_data ? array_data[x][y] : NULL); }
67 unsigned int sizeofPixel () const
70 unsigned int sizeofColumn () const
71 { return (sizeof(T) * m_ny); }
73 unsigned int sizeofArray () const
74 { return (sizeof(T) * m_nx * m_ny); }
87 array_data = new T*[m_nx];
89 for (unsigned int i = 0; i < m_nx; i++)
90 array_data[i] = new T[m_ny];
96 for (unsigned int i = 0; i < m_nx; i++)
97 delete array_data [i];
104 Array2d& operator= (const Array2d& rhs); //assignment operator
105 Array2d (const Array2d& rhs); // copy constructor