@@ -33,15 +33,15 @@ template <class T> class TVector {
33
33
34
34
TVector () {
35
35
N = 0 ;
36
- p = 0 ;
36
+ p = nullptr ;
37
37
ElementSize = sizeof (T);
38
38
}
39
39
~TVector () {
40
- if (p != 0 ) Delete ();
40
+ if (p != nullptr ) Delete ();
41
41
}
42
42
void NewVector (int VectorLength) {
43
43
if (VectorLength < 0 ) { std::exit (EXIT_FAILURE); }
44
- if (p != 0 && N == VectorLength) {
44
+ if (p != nullptr && N == VectorLength) {
45
45
Init ();
46
46
} else {
47
47
Delete ();
@@ -58,9 +58,9 @@ template <class T> class TVector {
58
58
void New (int VectorLength) { return NewVector (VectorLength); }
59
59
void NewVec (int VectorLength) { return NewVector (VectorLength); }
60
60
61
- void Delete (void ) {
62
- if (p != 0 && N != 0 ) { delete[] p; }
63
- p = 0 ;
61
+ void Delete () {
62
+ if (p != nullptr && N != 0 ) { delete[] p; }
63
+ p = nullptr ;
64
64
N = 0 ;
65
65
}
66
66
void CopyVec (const TVector &v) {
@@ -73,8 +73,8 @@ template <class T> class TVector {
73
73
mem = (long int )N * ElementSize;
74
74
std::memcpy (p, v.p , mem);
75
75
}
76
- void Init (void ) {
77
- if (p != 0 ) {
76
+ void Init () {
77
+ if (p != nullptr ) {
78
78
long int mem = (long int )N * ElementSize;
79
79
std::memset (p, 0 , mem);
80
80
}
@@ -104,20 +104,20 @@ template <class T> class TMatrix {
104
104
TMatrix () {
105
105
cols = 0 ;
106
106
rows = 0 ;
107
- p = 0 ;
107
+ p = nullptr ;
108
108
ElementSize = sizeof (T);
109
109
}
110
110
~TMatrix () {
111
- if (p != 0 ) Delete ();
111
+ if (p != nullptr ) Delete ();
112
112
}
113
113
114
114
void NewMatrix (int r, int c) {
115
115
if (r < 0 || c < 0 ) std::exit (EXIT_FAILURE);
116
- if (p != 0 && r == rows && c == cols) {
116
+ if (p != nullptr && r == rows && c == cols) {
117
117
Init ();
118
118
} else {
119
119
long int mem = (long int )r * (long int )c;
120
- if (p != 0 ) Delete (); // Eventually delete old matrix
120
+ if (p != nullptr ) Delete (); // Eventually delete old matrix
121
121
122
122
if (mem == 0 ) return ; // don't touch pointer if no memory is allocated
123
123
@@ -136,26 +136,26 @@ template <class T> class TMatrix {
136
136
void New (int r, int c) { return NewMatrix (r, c); }
137
137
void NewMat (int r, int c) { return NewMatrix (r, c); }
138
138
139
- void Delete (void ) {
140
- if (p != 0 && rows * cols != 0 ) { delete[] p; }
139
+ void Delete () {
140
+ if (p != nullptr && rows * cols != 0 ) { delete[] p; }
141
141
rows = 0 ;
142
142
cols = 0 ;
143
- p = 0 ;
143
+ p = nullptr ;
144
144
}
145
145
146
- void Init (void ) {
146
+ void Init () {
147
147
long int mem;
148
- if (p != 0 ) {
148
+ if (p != nullptr ) {
149
149
mem = (long int )cols * (long int )rows * ElementSize;
150
150
std::memset (p, 0 , mem);
151
151
}
152
152
}
153
153
154
- void Transpose (void ) {
154
+ void Transpose () {
155
155
T x;
156
156
int i, j;
157
157
158
- if (p != 0 ) {
158
+ if (p != nullptr ) {
159
159
if (rows == cols) {
160
160
for (i = 0 ; i < rows; i++) {
161
161
for (j = 0 ; j < i; j++) {
@@ -191,7 +191,7 @@ template <class T> class TMatrix {
191
191
std::memcpy (p, m.p , mem);
192
192
}
193
193
194
- void Print (char name[] = " unknown" ) {
194
+ void Print (const char name[] = " unknown" ) {
195
195
printf (" Matrix printed: %s (%d, %d)\n " , name, rows, cols);
196
196
for (int i = 0 ; i < rows; i++) {
197
197
for (int j = 0 ; j < cols; j++) {
0 commit comments