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-2001 Kevin Rosenberg
12 ** $Id: array2d.h,v 1.9 2001/01/28 19:10:18 kevin Exp $
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
31 #include "ctsupport.h"
37 Array2d (unsigned int x, unsigned int y)
38 : m_nx(x), m_ny(y), array_data(0)
44 : m_nx(0), m_ny(0), array_data(0)
52 void initSetSize (unsigned int x, unsigned int y)
61 { return array_data; }
63 T* getColumn (unsigned int x) const
64 { return (array_data ? array_data[x] : NULL); }
66 T getPoint (unsigned int x, unsigned int y) const
67 { return (array_data ? array_data[x][y] : NULL); }
69 unsigned int sizeofPixel () const
72 unsigned int sizeofColumn () const
73 { return (sizeof(T) * m_ny); }
75 unsigned int sizeofArray () const
76 { return (sizeof(T) * m_nx * m_ny); }
89 array_data = new T*[m_nx];
91 for (unsigned int i = 0; i < m_nx; i++)
92 array_data[i] = new T[m_ny];
98 for (unsigned int i = 0; i < m_nx; i++)
99 delete array_data [i];
106 Array2d& operator= (const Array2d& rhs); //assignment operator
107 Array2d (const Array2d& rhs); // copy constructor