File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717
1818 ******************************************************************************/
1919
20- #include < iostream>
2120#include " sbg/map.hpp"
2221
2322namespace SBG {
@@ -112,6 +111,14 @@ bool Map::operator!=(const Map &other) const
112111 return !(*this == other);
113112}
114113
114+ Map &Map::operator =(const Map &other)
115+ {
116+ dom_ = other.dom_ ;
117+ exp_ = other.exp_ ;
118+
119+ return *this ;
120+ }
121+
115122Map Map::operator +(const Map &other) const
116123{
117124 Set res_dom = dom_.intersection (other.dom ());
@@ -239,7 +246,7 @@ MaybeMap Map::compact(const Map &other) const
239246{
240247 Set res_dom = fact_.createSet ();
241248 if (exp_ == other.exp ())
242- return Map (fact_, dom_.cup (other.dom ()), exp_);
249+ return Map (fact_, dom_.cup (other.dom ()). compact () , exp_);
243250
244251 return {};
245252}
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ struct Map {
8484
8585 bool operator ==(const Map &other) const ;
8686 bool operator !=(const Map &other) const ;
87+ Map &operator =(const Map &other);
8788
8889 /* *
8990 * @brief Calculates the sum of both maps for elements that belong to both
Original file line number Diff line number Diff line change @@ -692,7 +692,34 @@ PWMapDelegPtr UnordPWMap::offsetImage(const Exp &off) const
692692// TODO
693693PWMapDelegPtr UnordPWMap::compact () const
694694{
695- return std::make_unique<UnordPWMap>(*this );
695+ UnordPWMap res (fact_);
696+
697+ if (dom ().isEmpty ())
698+ return std::make_unique<UnordPWMap>(res);
699+
700+ Set compacted = fact_.createSet ();
701+ for (auto it = pieces_.begin (); it != pieces_.end (); ++it) {
702+ auto next_it = it;
703+ ++next_it;
704+ Set ith_compacted = compacted.intersection (it->dom ());
705+ if (ith_compacted.isEmpty ()) {
706+ Map new_ith = fact_.createMap (it->dom ().compact (), it->exp ());
707+ for (; next_it != pieces_.end (); ++next_it) {
708+ Set next_compacted = compacted.intersection (next_it->dom ());
709+ if (next_compacted.isEmpty ()) {
710+ auto ith = new_ith.compact (*next_it);
711+ if (ith) {
712+ new_ith = ith.value ();
713+ compacted = compacted.cup (next_it->dom ());
714+ }
715+ }
716+ }
717+
718+ res.emplaceBack (new_ith);
719+ }
720+ }
721+
722+ return std::make_unique<UnordPWMap>(res);
696723}
697724
698725// //////////////////////////////////////////////////////////////////////////////
You can’t perform that action at this time.
0 commit comments