SDA (SDA flex)  7.2
Simulation of Diffusional Association
Loading...
Searching...
No Matches
ArrayPtr.hpp
Go to the documentation of this file.
1
14#ifndef ARRAYPTR_HPP_
15#define ARRAYPTR_HPP_
16#include "ArrayPrs.hpp"
17using namespace std;
18
19template<typename T, typename K>
20class ArrayPtr {
21
24
25public:
26
27 template <class M, class H>
28 friend class DTGrid2D;
29 template <class M, class H>
30 friend class DTGrid3D;
31 friend class DTGrid3Dex;
32 template <class M, class H>
33 friend class DTGrid1D;
34
35 //typedef ArrayPrs<K>* newtype;
37 void Set_Pointer_Array_Values(T *,K *,int, int);
39
40private:
41
44
47
50};
51
53
56template<typename T, typename K>
58 alloc_size1 = 0;
59 alloc_size2 = 0;
60}
61
63
67template<typename T, typename K>
69{
70 /*if (alloc_size1 != 0){
71 for (int i = 0; i < alloc_size1; i++){
72 delete PtrArray[i];
73 }
74 }*/
75 if (alloc_size1 != 0){
76 delete[] PtrArray;
77 }
78 else{
79 //delete PtrArray;
80 }
81 //delete PtrArray;
82 //delete PtrArray_Copy;
83 /*if (alloc_size2 != 0){
84 for (int i = 0; i < alloc_size2; i++){
85 delete PtrArrayReg[i];
86 }
87 }*/
88 if (alloc_size2 != 0){
89 delete[] PtrArrayReg;
90 }
91 else{
92 //delete PtrArrayReg;
93 }
94 //delete PtrArrayReg_Copy;
95}
96
98
107template<typename T, typename K>
109
110 alloc_size1 = J;
111 PtrArray = new (nothrow) typename ArrayPrs <K>::PairArray * [J];
112
113 int count = J-1;
114 for (;count>=0;count--) {
115
116 //PtrArray[count] = new (nothrow) typename ArrayPrs <K>::PairArray;
117 PtrArray[count] = &(pair_array[PtArray[count]]);
118 }
119 PtrArray_Copy = PtrArray;
120}
121
123
132template<typename T, typename K>
134
135 alloc_size2 = J;
136 PtrArrayReg = new (nothrow) T* [J];
137
138 int count = J-1;
139 for (;count>=0;count--) {
140
141 //PtrArrayReg[count] = new T;
142 PtrArrayReg[count] = &(pair_array[PtArray[count]]);
143 }
144 PtrArrayReg_Copy = PtrArrayReg;
145}
146
148
153template<typename T, typename K>
155 PtrArray_Copy = PtrArray;
156 PtrArrayReg_Copy = PtrArrayReg;
157}
158
159#endif /* ARRAYPTR_HPP_ */
Define the array for storing pairs of indices.
Definition ArrayPtr.hpp:20
int alloc_size2
Definition ArrayPtr.hpp:43
ArrayPrs< K >::PairArray ** PtrArray
Definition ArrayPtr.hpp:45
T ** PtrArrayReg
copy of the original pointer address.
Definition ArrayPtr.hpp:48
void Set_Pointer_Array_Values(typename ArrayPrs< K >::PairArray *, K *, int, int)
Setup the array that stores the IndexPair values.
Definition ArrayPtr.hpp:108
T ** PtrArrayReg_Copy
Definition ArrayPtr.hpp:49
ArrayPrs< K >::PairArray ** PtrArray_Copy
Definition ArrayPtr.hpp:46
~ArrayPtr()
ArrayPtr destructor.
Definition ArrayPtr.hpp:68
void Set_Pointer_Array_Values(T *, K *, int, int)
Setup the array that stores the IndexPair values.
Definition ArrayPtr.hpp:133
ArrayPtr()
ArrayPtr constructor.
Definition ArrayPtr.hpp:57
int alloc_size1
Definition ArrayPtr.hpp:42
void Reset_Set_Pointer_Array_Values(void)
Reset the address that the pointer stores.
Definition ArrayPtr.hpp:154
Definition DTGrid1D.hpp:13
Definition DTGrid2D.hpp:17
Definition DTGrid3D.hpp:65
Definition DTGrid3Dex.hpp:73
Imprint/Privacy