Skip to content

Commit 4fae15b

Browse files
committed
Debugged processMapsOrd
1 parent 90252f8 commit 4fae15b

7 files changed

Lines changed: 91 additions & 58 deletions

File tree

sbg/dom_ord_pwmap.cpp

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
******************************************************************************/
1919

2020
#include <forward_list>
21+
#include <iostream>
2122
#include <set>
2223

2324
#include "sbg/map_entry.hpp"
@@ -153,19 +154,28 @@ bool DomOrdPWMap::operator==(const PWMapStrategy& other) const
153154
// Comparison between short_map and long_map needed.
154155
if (doInt(short_sp, long_sp)) {
155156
Set cap_dom = short_map.dom().intersection(long_map.dom());
156-
Map short_cap_map(cap_dom, short_map.exp());
157-
Map long_cap_map(cap_dom, long_map.exp());
158-
if (!cap_dom.isEmpty() && short_cap_map != long_cap_map) {
159-
return false;
157+
if (!cap_dom.isEmpty()) {
158+
Exp short_exp = short_map.exp();
159+
Exp long_exp = long_map.exp();
160+
if (short_exp != long_exp) {
161+
return false;
162+
}
163+
164+
Map short_cap_map(cap_dom, short_exp);
165+
Map long_cap_map(cap_dom, long_exp);
166+
if (short_cap_map != long_cap_map) {
167+
return false;
168+
}
160169
}
161170
}
162171

163172
++prev_index;
164173
++curr_index;
165174
}
166175

167-
if (indexes.empty())
176+
if (indexes.empty()) {
168177
break;
178+
}
169179
}
170180

171181
return true;
@@ -196,7 +206,7 @@ PWMapStratPtr DomOrdPWMap::operator+(const PWMapStrategy& other) const
196206
void DomOrdPWMap::processAdd(const Map& m1, const Map& m2,
197207
Set& set_in, Set& set_out,
198208
OrdMapCollection& ord_pwmap,
199-
NAT global_pos) const
209+
NAT& global_pos) const
200210
{
201211
Map res_add = m1 + m2;
202212
if (!res_add.dom().isEmpty()) {
@@ -621,7 +631,7 @@ PWMapStratPtr DomOrdPWMap::minAdjMap(const PWMapStrategy& other) const
621631
void DomOrdPWMap::processMinAdjMap(const Map& m1, const Map& m2,
622632
Set& set_in, Set& set_out,
623633
OrdMapCollection& ord_pwmap,
624-
NAT global_pos) const
634+
NAT& global_pos) const
625635
{
626636
Set dom_res = SET_FACT.createSet();
627637
Set ith_dom = m1.dom().intersection(m2.dom());
@@ -735,7 +745,7 @@ Set DomOrdPWMap::equalImage(const PWMapStrategy& other) const
735745
void DomOrdPWMap::processEqualImage(const Map& m1, const Map& m2,
736746
Set& set_in, Set& set_out,
737747
OrdMapCollection& ord_pwmap,
738-
NAT global_pos) const
748+
NAT& global_pos) const
739749
{
740750
Set cap_dom = m1.dom().intersection(m2.dom());
741751
if (!cap_dom.isEmpty()) {
@@ -759,7 +769,7 @@ Set DomOrdPWMap::lessImage(const PWMapStrategy& other) const
759769
void DomOrdPWMap::processLessImage(const Map& m1, const Map& m2,
760770
Set& set_in, Set& set_out,
761771
OrdMapCollection& ord_pwmap,
762-
NAT global_pos) const
772+
NAT& global_pos) const
763773
{
764774
set_out.insertBack(m1.lessImage(m2));
765775
}
@@ -791,38 +801,41 @@ void DomOrdPWMap::processMapsOrd(
791801

792802
auto short_begin = short_pw->pieces_.begin();
793803
NAT global_pos = 0;
794-
795-
for(const MapEntry& long_mpe : long_pw->pieces_ ) {
804+
for (const MapEntry& long_mpe : long_pw->pieces_ ) {
796805
const Map& long_map = long_mpe.first;
797806
const SetPerimeter& long_sp = long_mpe.second;
798807

799808
auto prev_index = indexes.before_begin();
800809
auto curr_index = indexes.begin();
801-
802810
while (curr_index != indexes.end()) {
803811
size_t idx = *curr_index;
804812
const MapEntry& short_mpe = *(short_begin + idx);
805-
const Map& s_m = short_mpe.first;
813+
const Map& short_map = short_mpe.first;
806814
const SetPerimeter& short_sp = short_mpe.second;
807-
815+
808816
if (short_sp.second < long_sp.first) {
809817
curr_index = indexes.erase_after(prev_index);
810818
continue;
811819
}
812820

813-
if (long_sp.second < short_sp.first)
821+
if (long_sp.second < short_sp.first) {
814822
break;
823+
}
815824

816825
// Process overlapping perimeters
817826
if (doInt(short_sp, long_sp)) {
818-
(this->*process)(s_m, long_map, set_in, set_out, ord_map, global_pos);
827+
(this->*process)(short_map, long_map, set_in, set_out, ord_map
828+
, global_pos);
819829
}
820830

821831
++prev_index;
822832
++curr_index;
833+
//++aux_it;
823834
}
824-
if (indexes.empty())
835+
836+
if (indexes.empty()) {
825837
break;
838+
}
826839
}
827840
}
828841

sbg/dom_ord_pwmap.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ struct DomOrdPWMap : public OrdPWMap {
129129
Set& set_in,
130130
Set& set_out,
131131
OrdMapCollection& ord_pwmap,
132-
NAT global_pos) const;
132+
NAT& global_pos) const;
133133

134134
/**
135135
* @brief Calculates the minus core, which contains the entire main process of
@@ -141,7 +141,7 @@ struct DomOrdPWMap : public OrdPWMap {
141141
Set& set_in,
142142
Set& set_out,
143143
OrdMapCollection& ord_pwmap,
144-
NAT global_pos) const;
144+
NAT& global_pos) const;
145145

146146
/**
147147
* @brief Calculates the add core, which contains the entire main process of
@@ -153,7 +153,7 @@ struct DomOrdPWMap : public OrdPWMap {
153153
Set& set_in,
154154
Set& set_out,
155155
OrdMapCollection& ord_pwmap,
156-
NAT global_pos) const;
156+
NAT& global_pos) const;
157157

158158
/**
159159
* @brief Calculates the lessImage core, which contains the entire main
@@ -165,7 +165,7 @@ struct DomOrdPWMap : public OrdPWMap {
165165
Set& set_in,
166166
Set& set_out,
167167
OrdMapCollection& ord_pwmap,
168-
NAT global_pos) const;
168+
NAT& global_pos) const;
169169

170170
/**
171171
* @brief Calculates the equalImage core, which contains the entire main
@@ -177,16 +177,16 @@ struct DomOrdPWMap : public OrdPWMap {
177177
Set& set_in,
178178
Set& set_out,
179179
OrdMapCollection& ord_pwmap,
180-
NAT global_pos) const;
180+
NAT& global_pos) const;
181181

182182
/**
183183
* @brief Type used in the 'processMapsOrd' declaration to reduce its size.
184184
* This type is the same as the process functions above.
185185
*/
186186
using ProcessFunc = void (DomOrdPWMap::*)(
187-
const Map& , const Map& ,
188-
Set& , Set& , OrdMapCollection&,
189-
NAT
187+
const Map& , const Map& ,
188+
Set& , Set& , OrdMapCollection&,
189+
NAT&
190190
) const;
191191

192192
/**

sbg/map_entry.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
1818
******************************************************************************/
1919

20+
#include <iostream>
2021
#include "sbg/map_entry.hpp"
2122

2223
namespace SBG {
@@ -90,28 +91,29 @@ void emplaceHint(OrdMapCollection& ord_pw, const Map& m, NAT hint)
9091
auto end = ord_pw.end();
9192
MapEntry mpe = createMapEntry(m);
9293
while (it != end) {
93-
if (it->second.first < mpe.second.first)
94+
if (it->second.first < mpe.second.first) {
9495
++it;
95-
else
96+
} else {
9697
break;
98+
}
9799
}
98-
ord_pw.insert(it, mpe);
100+
ord_pw.emplace(it, mpe);
99101
}
100102
}
101103

102-
void advanceHint(OrdMapCollection& ord_pw, const MD_NAT crit, NAT hint)
104+
void advanceHint(OrdMapCollection& ord_pw, const MD_NAT crit, NAT& hint)
103105
{
104106
auto it = ord_pw.begin();
105-
std::advance(it,hint);
107+
std::advance(it, hint);
106108
auto end = ord_pw.end();
107-
while (it != end){
108-
if (it->second.first < crit){
109+
while (it != end) {
110+
if (it->second.first < crit) {
109111
++it;
110112
++hint;
111-
}
112-
else
113+
} else {
113114
break;
114-
}
115+
}
116+
}
115117
}
116118

117119
} // namespace Internal

sbg/map_entry.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bool operator<(const MapEntry& mpe1, const MapEntry& mpe2);
4545
void emplaceBack(OrdMapCollection& ord_pw, const MapEntry& entry);
4646
void emplaceBack(OrdMapCollection& ord_pw, const Map& m);
4747
void emplaceHint(OrdMapCollection& ord_pw, const Map& m, NAT hint);
48-
void advanceHint(OrdMapCollection& ord_pw, const MD_NAT crit, NAT hint);
48+
void advanceHint(OrdMapCollection& ord_pw, const MD_NAT crit, NAT& hint);
4949

5050
} // namespace Internal
5151

sbg/ord_pwmap.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,28 @@ bool OrdPWMap::operator==(const PWMapStrategy& other) const
145145

146146
if (doInt(short_sp, long_sp)) {
147147
Set cap_dom = short_map.dom().intersection(long_map.dom());
148-
Map short_cap_map(cap_dom, short_map.exp());
149-
Map long_cap_map(cap_dom, long_map.exp());
150-
if (!cap_dom.isEmpty() && short_cap_map != long_cap_map) {
151-
return false;
148+
if (!cap_dom.isEmpty()) {
149+
Exp short_exp = short_map.exp();
150+
Exp long_exp = long_map.exp();
151+
if (short_exp != long_exp) {
152+
return false;
153+
}
154+
155+
Map short_cap_map(cap_dom, short_exp);
156+
Map long_cap_map(cap_dom, long_exp);
157+
if (short_cap_map != long_cap_map) {
158+
return false;
159+
}
152160
}
153161
}
154162

155163
++prev_index;
156164
++curr_index;
157165
}
158-
if (indexes.empty())
166+
167+
if (indexes.empty()) {
159168
break;
169+
}
160170
}
161171

162172
return true;
@@ -204,7 +214,7 @@ PWMapStratPtr OrdPWMap::operator+(const PWMapStrategy& other) const
204214
void OrdPWMap::processAdd(const Map& m1, const Map& m2,
205215
Set& set_in, Set& set_out,
206216
OrdMapCollection& ord_pwmap,
207-
NAT global_pos) const
217+
NAT& global_pos) const
208218
{
209219
Map res_add = m1 + m2;
210220
if (!res_add.dom().isEmpty()){
@@ -596,7 +606,7 @@ PWMapStratPtr OrdPWMap::minAdjMap(const PWMapStrategy& other) const
596606
void OrdPWMap::processMinAdjMap(const Map& m1, const Map& m2,
597607
Set& set_in, Set& set_out,
598608
OrdMapCollection& ord_pwmap,
599-
NAT global_pos) const
609+
NAT& global_pos) const
600610
{
601611
Set dom_res = SET_FACT.createSet();
602612
Set ith_dom = m1.dom().intersection(m2.dom());
@@ -708,7 +718,7 @@ Set OrdPWMap::equalImage(const PWMapStrategy& other) const
708718
void OrdPWMap::processEqualImage(const Map& m1, const Map& m2,
709719
Set& set_in, Set& set_out,
710720
OrdMapCollection& ord_pwmap,
711-
NAT global_pos) const
721+
NAT& global_pos) const
712722
{
713723
Set cap_dom = m1.dom().intersection(m2.dom());
714724
if (!cap_dom.isEmpty()) {
@@ -732,7 +742,7 @@ Set OrdPWMap::lessImage(const PWMapStrategy& other) const
732742
void OrdPWMap::processLessImage(const Map& m1, const Map& m2,
733743
Set& set_in, Set& set_out,
734744
OrdMapCollection& ord_pwmap,
735-
NAT global_pos) const
745+
NAT& global_pos) const
736746
{
737747
set_out = set_out.disjointCup(m1.lessImage(m2));
738748
}
@@ -812,7 +822,7 @@ PWMapStratPtr OrdPWMap::offsetDom(const MD_NAT& off) const
812822
{
813823
OrdMapCollection res;
814824

815-
for (const MapEntry& mpe : pieces_){
825+
for (const MapEntry& mpe : pieces_) {
816826
Map map(mpe.first.dom().offset(off), mpe.first.exp());
817827
if(!map.isEmpty())
818828
Internal::emplaceBack(res, map);

sbg/ord_pwmap.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ struct OrdPWMap : public PWMapStrategy {
125125
Set& set_in,
126126
Set& set_out,
127127
OrdMapCollection& ord_pwmap,
128-
NAT global_pos) const;
128+
NAT& global_pos) const;
129129

130130
/**
131131
* @brief Calculates the minus core, which contains the entire main process of the function.
@@ -136,7 +136,7 @@ struct OrdPWMap : public PWMapStrategy {
136136
Set& set_in,
137137
Set& set_out,
138138
OrdMapCollection& ord_pwmap,
139-
NAT global_pos) const;
139+
NAT& global_pos) const;
140140

141141
/**
142142
* @brief Calculates the add core, which contains the entire main process of the function.
@@ -147,7 +147,7 @@ struct OrdPWMap : public PWMapStrategy {
147147
Set& set_in,
148148
Set& set_out,
149149
OrdMapCollection& ord_pwmap,
150-
NAT global_pos) const;
150+
NAT& global_pos) const;
151151

152152
/**
153153
* @brief Calculates the equalImage core, which contains the entire main process of the function.
@@ -158,7 +158,7 @@ struct OrdPWMap : public PWMapStrategy {
158158
Set& set_in,
159159
Set& set_out,
160160
OrdMapCollection& ord_pwmap,
161-
NAT global_pos) const;
161+
NAT& global_pos) const;
162162

163163
/**
164164
* @brief Calculates the lessImage core, which contains the entire main process of the function.
@@ -169,16 +169,16 @@ struct OrdPWMap : public PWMapStrategy {
169169
Set& set_in,
170170
Set& set_out,
171171
OrdMapCollection& ord_pwmap,
172-
NAT global_pos) const;
172+
NAT& global_pos) const;
173173

174174
/**
175175
* @brief Type used in the 'processMapsOrd' declaration to reduce its size.
176176
* This type is the same as the process functions above.
177177
*/
178178
using ProcessFunc = void (OrdPWMap::*)(
179-
const Map& , const Map& ,
180-
Set& , Set& , OrdMapCollection& ,
181-
NAT
179+
const Map& , const Map& ,
180+
Set& , Set& , OrdMapCollection& ,
181+
NAT&
182182
) const;
183183

184184
/**

0 commit comments

Comments
 (0)