C++ main module for gpm Package  1.0
CORE_Array3D.hpp
Go to the documentation of this file.
1 #ifndef CORE_Array3D_CPP
2 #define CORE_Array3D_CPP
3 
4 #include "CORE_Array3D.h"
5 #include "CORE_Integer.h"
6 #include "CORE_String.h"
7 
8 template<class T>
10  mN1=0;
11  mN2=0;
12  mN3=0;
13  mVector=null;
14 }
15 
16 template<class T>
18  for (int i=0;i<mN1;i++) {
19  for (int j=0;j<mN2;j++) {
20  delete[] mVector[i][j];
21  }
22  delete[] mVector[i];
23  }
24  delete[] mVector;
25 }
26 template<class T>
27 void CORE_Array3D<T>::setSize(const int& n,const int& p,const int& q) {
28  if (mVector!=null) {
29  for (int i=0;i<mN1;i++) {
30  for (int j=0;j<mN2;j++) {
31  delete[] mVector[i][j];
32  }
33  delete[] mVector[i];
34  }
35  delete[] mVector;
36  }
37  mVector=new T**[n];
38  for (int i=0;i<n;i++) {
39  mVector[i]=new T*[p];
40  for (int j=0;j<p;j++) mVector[i][j]=new T[q];
41  }
42  mN1=n;
43  mN2=p;
44  mN3=q;
45 }
46 
47 template<class T>
49  if (this==&src) return;
50  int n,p,q;
51  src.getSize(n,p,q);
52  setSize(n,p,q);
53  for (int i=0;i<n;i++) {
54  for (int j=0;j<p;j++) {
55  for (int k=0;k<q;k++) {
56  mVector[i][j][k]=src[i][j][k];
57  }
58  }
59  }
60 
61 }
62 
63 template<class T>
65  tString str("");
66  str+="size:"+CORE_Integer::toString(mN1)+"x"+CORE_Integer::toString(mN2)+"x"+CORE_Integer::toString(mN3)+"\n";
67 
68  for (int i=0;i<mN1;i++) {
69  for (int j=0;j<mN2;j++) {
70  for (int k=0;k<mN3;k++) {
71  str+=CORE_String::toString(mVector[i][j][k]);
72  str+="\t";
73  }
74  str+="\n";
75  }
76  }
77 
78  return str;
79 }
80 
81 #endif
tString toString() const
turn the array into string
Definition: CORE_Array3D.hpp:64
void getSize(int &n, int &p, int &q) const
return the size of the array
Definition: CORE_Array3D.h:120
tString toString() const
return the string associated to the string
Definition: CORE_String.h:150
this class describes an array of arrays
Definition: CORE_Array3D.h:13
this class describes a list
Definition: CORE_List.h:12
void setSize(const int &n, const int &p, const int &q)
set the size of the array
Definition: CORE_Array3D.hpp:27
void copy(const CORE_Array3D< T > &src)
void copy
Definition: CORE_Array3D.hpp:48
#define null
Definition: types.h:13
CORE_Array3D()
build an array of T*
Definition: CORE_Array3D.hpp:9
tString toString() const
return the string associated to the integer
Definition: CORE_Integer.h:142
#define tString
Definition: types.h:36
virtual ~CORE_Array3D()
destroy an array of T*
Definition: CORE_Array3D.hpp:17