Skip to content

Commit f337809

Browse files
committed
Generalized perimeter
1 parent ad0bc25 commit f337809

16 files changed

Lines changed: 55 additions & 38 deletions

sbg/interval.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ Interval Interval::offset(const NAT off) const
178178
return Interval{_begin + off, _step, _end + off};
179179
}
180180

181+
Perimeter Interval::perimeter() const { return Perimeter(_begin, _end); }
182+
181183
MaybeInterval Interval::compact(const Interval& other) const
182184
{
183185
if (_step == other._step) {

sbg/interval.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define SBGRAPH_SBG_INTERVAL_HPP_
3333

3434
#include "sbg/natural.hpp"
35+
#include "sbg/perimeter.hpp"
3536

3637
#include <iosfwd>
3738
#include <optional>
@@ -84,6 +85,8 @@ class Interval {
8485
*/
8586
Interval offset(const NAT off) const;
8687

88+
Perimeter perimeter() const;
89+
8790
/**
8891
* @brief Merge two contiguous intervals if possible. If not, then the result
8992
* is not an interval, so no value is returned.

sbg/map_entry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ MapEntry::MapEntry(const Map& m)
3737

3838
const Map& MapEntry::map() const { return _map; }
3939

40-
const SetPerimeter& MapEntry::perimeter() const { return _perimeter; }
40+
const Perimeter& MapEntry::perimeter() const { return _perimeter; }
4141

4242
bool MapEntry::operator==(const MapEntry& other) const
4343
{

sbg/map_entry.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "sbg/expression.hpp"
3030
#include "sbg/map.hpp"
3131
#include "sbg/set.hpp"
32-
#include "sbg/set_perimeter.hpp"
32+
#include "sbg/perimeter.hpp"
3333

3434
#include <optional>
3535

@@ -49,7 +49,7 @@ class MapEntry {
4949
MapEntry(const Map& m);
5050

5151
const Map& map() const;
52-
const SetPerimeter& perimeter() const;
52+
const Perimeter& perimeter() const;
5353

5454
bool operator==(const MapEntry& other) const;
5555
bool operator<(const MapEntry& other) const;
@@ -58,7 +58,7 @@ class MapEntry {
5858

5959
private:
6060
Map _map;
61-
SetPerimeter _perimeter;
61+
Perimeter _perimeter;
6262
};
6363

6464
} // namespace detail

sbg/multidim_inter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ MultiDimInter MultiDimInter::least(const MultiDimInter& other) const
216216
return std::min(*this, other);
217217
}
218218

219+
Perimeter MultiDimInter::perimeter() const
220+
{
221+
return Perimeter{minElem(), maxElem()};
222+
}
223+
219224
MaybeMDI MultiDimInter::compact(const MultiDimInter& other) const
220225
{
221226
MultiDimInter result;

sbg/multidim_inter.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include "sbg/interval.hpp"
3232
#include "sbg/natural.hpp"
33+
#include "sbg/perimeter.hpp"
3334

3435
#include <iosfwd>
3536
#include <optional>
@@ -122,6 +123,8 @@ class MultiDimInter {
122123
*/
123124
MultiDimInter least(const MultiDimInter& other) const;
124125

126+
Perimeter perimeter() const;
127+
125128
/**
126129
* @brief Merge two contiguous mdis if possible. If not, then the result is
127130
* not an mdi, so no value is returned.

sbg/ord_set.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ OrderedSet OrderedSet::offset(const MD_NAT& off) const
611611
return result;
612612
}
613613

614-
SetPerimeter OrderedSet::perimeter() const
614+
Perimeter OrderedSet::perimeter() const
615615
{
616616
MD_NAT min;
617617
MD_NAT max;
@@ -630,7 +630,7 @@ SetPerimeter OrderedSet::perimeter() const
630630
}
631631
}
632632

633-
return SetPerimeter{min, max};
633+
return Perimeter{min, max};
634634
}
635635

636636
void OrderedSet::compact()

sbg/ord_set.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "sbg/interval.hpp"
3030
#include "sbg/multidim_inter.hpp"
3131
#include "sbg/natural.hpp"
32-
#include "sbg/set_perimeter.hpp"
32+
#include "sbg/perimeter.hpp"
3333

3434
#include <iosfwd>
3535
#include <memory>
@@ -90,7 +90,7 @@ class OrderedSet {
9090
OrderedSet disjointCup(OrderedSet&& other) const &;
9191
OrderedSet disjointCup(OrderedSet&& other) &&;
9292
OrderedSet offset(const MD_NAT& off) const;
93-
SetPerimeter perimeter() const;
93+
Perimeter perimeter() const;
9494
void compact();
9595

9696
private:
@@ -114,6 +114,8 @@ class OrderedSet {
114114
OrderedSet complementAtom() const;
115115

116116
OrdMDICollection _pieces;
117+
118+
friend class SetAccessKey;
117119
};
118120

119121
} // namespace detail

sbg/ord_unidim_dense_set.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ OrdUnidimDenseSet OrdUnidimDenseSet::difference(const OrdUnidimDenseSet& other)
365365
OrdUnidimDenseSet OrdUnidimDenseSet::cartesianProduct(const OrdUnidimDenseSet&
366366
other) const
367367
{
368-
Util::ERROR("OrdUnidimDenseSet::cartesianProduct: operation not supported");
368+
Util::ERROR("OrdUnidimDenseSet::cartesianProduct: operation not supported\n");
369369

370370
return OrdUnidimDenseSet{};
371371
}
@@ -433,9 +433,9 @@ OrdUnidimDenseSet OrdUnidimDenseSet::offset(const MD_NAT& offset) const
433433
return result;
434434
}
435435

436-
SetPerimeter OrdUnidimDenseSet::perimeter() const
436+
Perimeter OrdUnidimDenseSet::perimeter() const
437437
{
438-
return SetPerimeter{minElem(), maxElem()};
438+
return Perimeter{minElem(), maxElem()};
439439
}
440440

441441
void OrdUnidimDenseSet::compact()

sbg/ord_unidim_dense_set.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "sbg/interval.hpp"
3333
#include "sbg/multidim_inter.hpp"
3434
#include "sbg/natural.hpp"
35-
#include "sbg/set_perimeter.hpp"
35+
#include "sbg/perimeter.hpp"
3636

3737
#include <iosfwd>
3838
#include <memory>
@@ -92,7 +92,7 @@ class OrdUnidimDenseSet {
9292
OrdUnidimDenseSet disjointCup(OrdUnidimDenseSet&& other) const &;
9393
OrdUnidimDenseSet disjointCup(OrdUnidimDenseSet&& other) &&;
9494
OrdUnidimDenseSet offset(const MD_NAT& offset) const;
95-
SetPerimeter perimeter() const;
95+
Perimeter perimeter() const;
9696
void compact();
9797

9898
private:
@@ -117,6 +117,8 @@ class OrdUnidimDenseSet {
117117

118118
private:
119119
OrdIntervalCollection _pieces;
120+
121+
friend class SetAccessKey;
120122
};
121123

122124
} // namespace detail

0 commit comments

Comments
 (0)