projects
/
ctsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix test syntax errors in configure.ac
[ctsim.git]
/
include
/
array2d.h
diff --git
a/include/array2d.h
b/include/array2d.h
index d9081dbd829598a056e697c672b89761ddd7eb1b..d397e5f45160ce4824f5245eca3bfed47efe9cad 100644
(file)
--- a/
include/array2d.h
+++ b/
include/array2d.h
@@
-1,15
+1,13
@@
/*****************************************************************************
** FILE IDENTIFICATION
**
/*****************************************************************************
** FILE IDENTIFICATION
**
-** Name: array2d.h
+**
Name: array2d.h
** Purpose: 2-dimension array classes
** Purpose: 2-dimension array classes
-** Programmer: Kevin Rosenberg
-** Date Started: June 2000
+**
Programmer: Kevin Rosenberg
+**
Date Started: June 2000
**
** This is part of the CTSim program
**
** This is part of the CTSim program
-** Copyright (c) 1983-2001 Kevin Rosenberg
-**
-** $Id$
+** Copyright (c) 1983-2009 Kevin Rosenberg
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
@@
-31,49
+29,49
@@
#include "ctsupport.h"
#include "ctsupport.h"
-template<class T>
+template<class T>
class Array2d {
public:
Array2d (unsigned int x, unsigned int y)
class Array2d {
public:
Array2d (unsigned int x, unsigned int y)
- : m_nx(x), m_ny(y), array_data(0)
- {
- allocArray();
- }
+
: m_nx(x), m_ny(y), array_data(0)
+
{
+
allocArray();
+
}
Array2d ()
Array2d ()
- : m_nx(0), m_ny(0), array_data(0)
- {}
+
: m_nx(0), m_ny(0), array_data(0)
+
{}
~Array2d ()
~Array2d ()
- {
- deleteArray();
- }
-
+
{
+
deleteArray();
+
}
+
void initSetSize (unsigned int x, unsigned int y)
void initSetSize (unsigned int x, unsigned int y)
- {
- m_nx = x;
- m_ny = y;
- deleteArray();
- allocArray();
- }
+
{
+
m_nx = x;
+
m_ny = y;
+
deleteArray();
+
allocArray();
+
}
T** getArray () const
T** getArray () const
- { return array_data; }
+
{ return array_data; }
T* getColumn (unsigned int x) const
T* getColumn (unsigned int x) const
- { return (array_data ? array_data[x] : NULL); }
+
{ return (array_data ? array_data[x] : NULL); }
T getPoint (unsigned int x, unsigned int y) const
T getPoint (unsigned int x, unsigned int y) const
- { return (array_data ? array_data[x][y] : NULL); }
+
{ return (array_data ? array_data[x][y] : NULL); }
- unsigned int sizeofPixel () const
- { return sizeof(T); }
+ unsigned int sizeofPixel () const
+
{ return sizeof(T); }
unsigned int sizeofColumn () const
unsigned int sizeofColumn () const
- { return (sizeof(T) * m_ny); }
+
{ return (sizeof(T) * m_ny); }
unsigned int sizeofArray () const
unsigned int sizeofArray () const
- { return (sizeof(T) * m_nx * m_ny); }
+
{ return (sizeof(T) * m_nx * m_ny); }
private:
private:
@@
-82,25
+80,25
@@
class Array2d {
T** array_data;
void allocArray ()
T** array_data;
void allocArray ()
- {
- if (array_data)
- deleteArray();
+ {
+ if (array_data)
+ deleteArray();
+
+ array_data = new T*[m_nx];
- array_data = new T*[m_nx];
-
- for (unsigned int i = 0; i < m_nx; i++)
- array_data[i] = new T[m_ny];
- }
+ for (unsigned int i = 0; i < m_nx; i++)
+ array_data[i] = new T[m_ny];
+ }
void deleteArray ()
void deleteArray ()
- {
- if (array_data) {
- for (unsigned int i = 0; i < m_nx; i++)
- delete array_data [i];
- delete array_data;
- array_data = NULL;
- }
- }
+
{
+
if (array_data) {
+
for (unsigned int i = 0; i < m_nx; i++)
+
delete array_data [i];
+
delete array_data;
+
array_data = NULL;
+
}
+
}
Array2d& operator= (const Array2d& rhs); //assignment operator
Array2d& operator= (const Array2d& rhs); //assignment operator