Skip to content

Commit b827a77

Browse files
authored
Merge branch 'master' into add-new-system-tests-for-next-and-call
2 parents 4c262c1 + 7dc4bfd commit b827a77

File tree

3 files changed

+60
-20
lines changed

3 files changed

+60
-20
lines changed

Team20/Code20/source/PKB.cpp renamed to Team20/Code20/source/Pkb.cpp

+16-4
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,21 @@ void Pkb::deriveTables() {
154154
PkbTableTransformers::pseudoinvertFlattenKeys<LINE_NO, NEXT>(
155155
this->nextsTable);
156156

157-
this->closeFollowTable = PkbTableTransformers::close(this->followTable);
158-
this->closeParentTable = PkbTableTransformers::close(this->parentTable);
159-
this->closePrevLineTable = PkbTableTransformers::close(prevLineTable);
157+
if (!followTable.map.empty()) {
158+
this->closeFollowTable = PkbTableTransformers::closeWarshall(
159+
PkbTableTransformers::closeOnce(this->followTable));
160+
}
161+
162+
if (!parentTable.map.empty()) {
163+
this->closeParentTable = PkbTableTransformers::closeWarshall(
164+
PkbTableTransformers::closeOnce(this->parentTable));
165+
}
166+
167+
if (!prevLineTable.map.empty()) {
168+
this->closePrevLineTable = PkbTableTransformers::closeWarshall(
169+
PkbTableTransformers::closeOnce(prevLineTable));
170+
}
171+
160172
this->closeChildrenTable =
161173
PkbTableTransformers::closeFlatten<PARENT>(childrenTable);
162174
this->closeCallsTable =
@@ -344,7 +356,7 @@ void Pkb::deriveAllAffectsBipRelatedTables() {
344356
void Pkb::deriveAllCloseAffectsBipRelatedTables() {
345357
deriveAllAffectsBipRelatedTables();
346358
this->closeAffectsBipTable =
347-
PkbTableTransformers::closeFlatten<LINE_NO>(this->affectsBipTable);
359+
PkbTableTransformers::closeWarshall(this->affectsBipTable);
348360
this->closeInvertAffectsBipTable =
349361
PkbTableTransformers::pseudoinvertFlattenKeys<LINE_NO, LINE_NO>(
350362
this->closeAffectsBipTable);

Team20/Code20/source/PkbTableTransformers.h

+16-16
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,6 @@ class PkbTableTransformers {
1717
static std::vector<std::vector<bool>> closeWarshallReachabilityMatrix(
1818
KeysTable<std::size_t, std::unordered_set<std::size_t>> keysTable);
1919

20-
/** @brief Composes keysTable with itself, once.
21-
Where `result` is the returned value, firstly copies keysTable.map to `result`
22-
by iterating through each key in keysTable.keys to get the value mapped by
23-
keysTable.map, to insert the key-value pair in `result`. Then, iterating
24-
through each key in keysTable.keys to get the key-values pair p1 in `result`,
25-
for each p1.value in p1.values, for each key-values pair p2 in `result` with
26-
p2.key equivalent to p1.value, concatenates the unordered_set of values
27-
`result[p1.key]` with p2.values.
28-
@param keysTable An associative container that contains key-values pairs with
29-
unique keys. There is a binary relation between keys and values.
30-
@return The composition of keysTable with itself.
31-
*/
32-
template <class T>
33-
static KeysTable<T, std::unordered_set<T>>
34-
closeOnce(KeysTable<T, T> keysTable);
35-
3620
/** @brief Auxiliary function of PkbTableTransformers::closeFlatten. For
3721
algorithm details, see PkbTableTransformers::closeFlatten.
3822
@param parent The parent for which all its descendants will be recursively
@@ -49,6 +33,22 @@ class PkbTableTransformers {
4933
KeysTable<T, std::unordered_set<T>> &mapCloseFlattened);
5034

5135
public:
36+
/** @brief Composes keysTable with itself, once.
37+
Where `result` is the returned value, firstly copies keysTable.map to `result`
38+
by iterating through each key in keysTable.keys to get the value mapped by
39+
keysTable.map, to insert the key-value pair in `result`. Then, iterating
40+
through each key in keysTable.keys to get the key-values pair p1 in `result`,
41+
for each p1.value in p1.values, for each key-values pair p2 in `result` with
42+
p2.key equivalent to p1.value, concatenates the unordered_set of values
43+
`result[p1.key]` with p2.values.
44+
@param keysTable An associative container that contains key-values pairs with
45+
unique keys. There is a binary relation between keys and values.
46+
@return The composition of keysTable with itself.
47+
*/
48+
template <class T>
49+
static KeysTable<T, std::unordered_set<T>>
50+
closeOnce(KeysTable<T, T> keysTable);
51+
5252
/** @brief Composes two tables, where variantTable maps to a `std::variant`.
5353
@param variantTable Table that maps keys `T` to a `std::variant` of values `V`
5454
and intermediate values `U`.

Team20/Code20/source/SetUpTests.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,34 @@ SetUpTests::SetUpTests(Pkb &pkb, TestNumber testNumber) {
573573
26 a = k + c}
574574
*/
575575

576+
pkbTables->addFollow(l1, l2);
577+
pkbTables->addFollow(l2, l3);
578+
pkbTables->addFollow(l3, l6);
579+
pkbTables->addFollow(l4, l5);
580+
pkbTables->addFollow(l7, l8);
581+
pkbTables->addFollow(l8, l9);
582+
pkbTables->addFollow(l9, l10);
583+
pkbTables->addFollow(l10, l11);
584+
pkbTables->addFollow(l12, l13);
585+
pkbTables->addFollow(l13, l14);
586+
pkbTables->addFollow(l14, l25);
587+
pkbTables->addFollow(l15, l23);
588+
pkbTables->addFollow(l16, l17);
589+
pkbTables->addFollow(l17, l19);
590+
591+
pkbTables->addParent(l4, l3);
592+
pkbTables->addParent(l5, l3);
593+
pkbTables->addParent(l15, l14);
594+
pkbTables->addParent(l23, l14);
595+
pkbTables->addParent(l16, l15);
596+
pkbTables->addParent(l17, l15);
597+
pkbTables->addParent(l19, l15);
598+
pkbTables->addParent(l22, l15);
599+
pkbTables->addParent(l18, l17);
600+
pkbTables->addParent(l20, l19);
601+
pkbTables->addParent(l21, l19);
602+
pkbTables->addParent(l24, l23);
603+
576604
Pkb::VAR vx = "x", vy = "y", vr = "r", vm = "m", vq = "q", vt = "t",
577605
vk = "k", vn = "n", vc = "c", va = "a";
578606
Pkb::PROC paux = "aux", pmain = "main", pcomplicate = "complicate",

0 commit comments

Comments
 (0)