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-2000 Kevin Rosenberg
12 ** $Id: array2d.h,v 1.7 2000/07/13 07:03:21 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 : nx(x), ny(y), array_data(0)
44 : nx(0), ny(0), array_data(0)
52 void initSetSize (unsigned int x, unsigned int y)
60 T** getArray (void) const
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 (void) const
72 unsigned int sizeofColumn (void) const
73 { return (sizeof(T) * ny); }
75 unsigned int sizeofArray (void) const
76 { return (sizeof(T) * nx * ny); }
84 void allocArray (void)
86 array_data = new T*[nx];
88 for (unsigned int i = 0; i < nx; i++)
89 array_data[i] = new T[ny];
92 void deleteArray (void)
95 for (unsigned int i = 0; i < nx; i++)
102 Array2d& operator= (const Array2d& rhs); //assignment operator
103 Array2d (const Array2d& rhs); // copy constructor