delphi_cb
 All Classes Namespaces Files Functions Variables Macros
space_templates.h
1 #ifndef SPACE_TEMPLATES_H
2 #define SPACE_TEMPLATES_H
3 
4 #include "../interface/environment.h"
5 
6 //template <class T> T ** get_pt2d(const delphi_integer& length, const delphi_integer& width)
7 template <class T> void get_pt2d(T ** & pt2d, const delphi_integer& length, const delphi_integer& width)
8 {
9  delphi_integer i;
10  //T ** pt2d;
11 
12  pt2d= new T *[length];
13  for (i=0; i<length; i++)
14  {
15  pt2d[i] = new T [width]();
16 
17  }
18 
19  //return (pt2d);
20 }
21 
22 //template <class T> T *** get_pt3d(const delphi_integer& length, const delphi_integer& width, const delphi_integer& hight)
23 template <class T> void get_pt3d(T *** & pt3d, const delphi_integer& length, const delphi_integer& width, const delphi_integer& hight)
24 //template <class T> T *** get_pt3d( delphi_integer& length, delphi_integer& width, delphi_integer& hight)
25 {
26  delphi_integer i,j;
27  //T *** pt3d;
28 
29  pt3d= new T **[length];
30  for (i=0; i<length; i++)
31  {
32  pt3d[i] = new T* [width];
33  for (j=0; j<width; j++)
34  {
35  pt3d[i][j]= new T[hight]();
36  }
37  }
38 
39  //return (pt3d);
40 }
41 
42 //template <class T> T **** get_pt4d(const delphi_integer& length, const delphi_integer& width, const delphi_integer& hight, const delphi_integer& page)
43 template <class T> void get_pt4d(T **** & pt4d, const delphi_integer& length, const delphi_integer& width, const delphi_integer& hight, const delphi_integer& page)
44 //template <class T> T *** get_pt3d( delphi_integer& length, delphi_integer& width, delphi_integer& hight)
45 {
46  delphi_integer i,j,k;
47  //T **** pt4d;
48 
49  pt4d= new T ***[length];
50  for (i=0; i<length; i++)
51  {
52  pt4d[i] = new T** [width];
53  for (j=0; j<width; j++)
54  {
55  pt4d[i][j]= new T* [hight];
56  for(k=0; k<hight; k++){
57  pt4d[i][j][k]= new T [page]();
58  }
59  }
60  }
61 
62  //return (pt4d);
63 }
64 
65 
66 
67 template <class T> void free_pt2d(T ** & pt2d, const delphi_integer& length, const delphi_integer& width)
68 {
69  delphi_integer i;
70 
71 
72  pt2d= new T *[length];
73  for (i=0; i<length; i++)
74  {
75  //pt2d[i] = new T [width]();
76  delete [] pt2d[i];
77  }
78  delete [] pt2d;
79  pt2d=NULL;
80 
81 }
82  template <class T> void free_pt3d(T *** & pt3d, const delphi_integer& length, const delphi_integer& width, const delphi_integer& hight)
83 //template <class T> T *** get_pt3d( delphi_integer& length, delphi_integer& width, delphi_integer& hight)
84 {
85  delphi_integer i,j;
86  //T *** pt3d;
87 
88  //pt3d= new T **[length];
89  for (i=0; i<length; i++)
90  {
91  //pt3d[i] = new T* [width];
92  for (j=0; j<width; j++)
93  {
94  //pt3d[i][j]= new T[hight]();
95  delete [] pt3d[i][j];
96  }
97  delete [] pt3d[i];
98 
99  }
100  delete [] pt3d;
101  pt3d=NULL;
102 }
103 
104 
105 
106 template <class T> void free_pt4d(T **** & pt4d, const delphi_integer& length, const delphi_integer& width, const delphi_integer& hight, const delphi_integer& page)
107 //template <class T> T *** get_pt3d( delphi_integer& length, delphi_integer& width, delphi_integer& hight)
108 {
109  delphi_integer i,j,k;
110 
111 
112  //pt4d= new T ***[length];
113  for (i=0; i<length; i++)
114  {
115  //pt4d[i] = new T** [width];
116  for (j=0; j<width; j++)
117  {
118  //pt4d[i][j]= new T* [hight];
119  for(k=0; k<hight; k++){
120  //pt4d[i][j][k]= new T [page]();
121  delete [] pt4d[i][j][k];
122  }
123  delete [] pt4d[i][j];
124  }
125  delete [] pt4d[i];
126  }
127  delete [] pt4d;
128  pt4d=NULL;
129 }
130 
131 
132 
133 /*
134 // Move index:
135 //template <class T> T ** Move_index_2d(T ** ptr_old,const int& length, const int& width)
136 template <class T> void Move_index_2d(T ** & ptr_new, T ** & ptr_old,const int& length, const int& width)
137 {
138  int i;
139  //T ** ptr_new;
140  ptr_new=new T *[length+1];
141  for(i=0;i<=length-1;i++){
142  ptr_new[i+1] = new T [width+1];
143  ptr_new[i+1]=ptr_old[i]-1;
144  }
145  //return(ptr_new);
146 
147 }
148 
149 //template <class T> T *** Move_index_3d(T *** ptr_old,const int& length, const int& width, const int& height)
150 template <class T> void Move_index_3d(T *** & ptr_new, T *** & ptr_old,const int& length, const int& width, const int& height)
151 {
152  int i,j;
153  //T *** ptr_new;
154 
155  ptr_new=new T ** [length+1];
156  for(i=0;i<=length-1;i++){
157  ptr_new[i+1] = new T * [width+1];
158  for(j=0;j<=width-1;j++){
159  //cout << "i,j: " << i << j << endl;
160  ptr_new[i+1][j+1] = new T [height+1];
161  ptr_new[i+1][j+1]=ptr_old[i][j]-1;
162  }
163  }
164  //return(ptr_new);
165 
166 }
167 
168 template <class T> void free_index_3d(T *** & ptr_new,const int& length, const int& width, const int& height)
169 {
170  int i,j;
171  //T *** ptr_new;
172 
173 
174  for(i=2;i<=length-1;i++){
175 
176  for(j=2;j<=width-1;j++){
177  //cout << "i,j: " << i << j << endl;
178  cout << "### i,j: " << i << j << endl;
179  delete [] ptr_new[i][j];
180 
181  //ptr_new[i+1][j+1]=ptr_old[i][j]-1;
182  }
183 
184  delete [] ptr_new[i];
185 
186  }
187 
188  delete [] ptr_new;
189  //return(ptr_new);
190 
191 }
192 */
193 
194 #endif // SPACE_TEMPLATES_H