Skip to content

Commit 00189d2

Browse files
author
alielabridi
committed
Revert "saving array to try to play with message with vectors"
This reverts commit 5633f56.
1 parent 05fb462 commit 00189d2

File tree

1 file changed

+22
-38
lines changed

1 file changed

+22
-38
lines changed

ValueMsg.h

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,25 @@
33

44
class ValueMsg : public CMessage_ValueMsg {
55
public:
6-
int** v;
6+
std::vector<std::vector<int> > v;
77
//i found a solution to allocate a non fixed sized without segment fault
8-
ValueMsg(int size){
9-
v = new int*[size];
10-
for (int i = 0; i < size; ++i){
11-
v[i] = new int[size];
12-
}
8+
ValueMsg(int size):v(size, std::vector<int>(size)){}
9+
ValueMsg(){}
1310

14-
15-
}
1611
//for the time being i am going to stick to array as vectors produce segment fault
1712
//int v[4][4];
1813
};
1914

2015

2116
class AddSubMsg : public CMessage_AddSubMsg {
2217
public:
23-
int** A;
24-
int** B;
18+
std::vector<std::vector<int> > A;
19+
std::vector<std::vector<int> > B;
2520
//i found a solution to allocate a non fixed sized without segment fault
21+
AddSubMsg(){}
2622
AddSubMsg(int size){
27-
A = new int*[size];
28-
B = new int*[size];
29-
for (int i = 0; i < size; ++i){
30-
A[i] = new int[size];
31-
B[i] = new int[size];
32-
}
23+
A = std::vector<std::vector<int>> (size,std::vector<int>(size));
24+
B = std::vector<std::vector<int>> (size,std::vector<int>(size));
3325
}
3426

3527
//for the time being i am going to stick to array as vectors produce segment fault
@@ -39,16 +31,13 @@ class AddSubMsg : public CMessage_AddSubMsg {
3931

4032
class StrassenMsg : public CMessage_StrassenMsg {
4133
public:
42-
int** A;
43-
int** B;
34+
std::vector<std::vector<int> > A;
35+
std::vector<std::vector<int> > B;
4436
//i found a solution to allocate a non fixed sized without segment fault
37+
StrassenMsg(){}
4538
StrassenMsg(int size){
46-
A = new int*[size];
47-
B = new int*[size];
48-
for (int i = 0; i < size; ++i){
49-
A[i] = new int[size];
50-
B[i] = new int[size];
51-
}
39+
A = std::vector<std::vector<int>> (size,std::vector<int>(size));
40+
B = std::vector<std::vector<int>> (size,std::vector<int>(size));
5241
}
5342

5443
//for the time being i am going to stick to array as vectors produce segment fault
@@ -58,23 +47,18 @@ class StrassenMsg : public CMessage_StrassenMsg {
5847

5948
class StrassenSubMsg : public CMessage_StrassenSubMsg {
6049
public:
61-
int** A;
62-
int** B;
63-
int** C;
64-
int** D;
50+
std::vector<std::vector<int> > A;
51+
std::vector<std::vector<int> > B;
52+
std::vector<std::vector<int> > C;
53+
std::vector<std::vector<int> > D;
6554
//i found a solution to allocate a non fixed sized without segment fault
55+
StrassenSubMsg(){}
6656

6757
StrassenSubMsg(int size){
68-
A = new int*[size];
69-
B = new int*[size];
70-
C = new int*[size];
71-
D = new int*[size];
72-
for (int i = 0; i < size; ++i){
73-
A[i] = new int[size];
74-
B[i] = new int[size];
75-
C[i] = new int[size];
76-
D[i] = new int[size];
77-
}
58+
A = std::vector<std::vector<int>> (size,std::vector<int>(size));
59+
B = std::vector<std::vector<int>> (size,std::vector<int>(size));
60+
C = std::vector<std::vector<int>> (size,std::vector<int>(size));
61+
D = std::vector<std::vector<int>> (size,std::vector<int>(size));
7862
}
7963

8064
//for the time being i am going to stick to array as vectors produce segment fault

0 commit comments

Comments
 (0)