-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDomain.h
More file actions
54 lines (42 loc) · 1.5 KB
/
Domain.h
File metadata and controls
54 lines (42 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef INTERVAL_ANALYSIS_DOMAIN_H
#define INTERVAL_ANALYSIS_DOMAIN_H
#include "Interval.h"
class Domain {
static Interval xDomain;
static Interval yDomain;
public:
class domain_iterator : public std::iterator<Interval, Interval, const Interval *, Interval> {
double xDist, yDist;
double xVal, yVal;
public:
domain_iterator(const unsigned GRID_FACTOR) : xDist(xDomain.width() / GRID_FACTOR),
yDist(yDomain.width() / GRID_FACTOR),
xVal(xDomain.get_lo()),
yVal(yDomain.get_lo()) {}
domain_iterator &operator++() {
xVal += xDist;
yVal += yDist;
return *this;
}
domain_iterator operator++(int) {
domain_iterator res = *this;
++(*this);
return res;
}
bool operator==(domain_iterator other) const {
return (xVal == other.xVal and yVal == other.yVal);
}
bool operator!=(domain_iterator other) const {
return !(*this == other);
}
pair<Interval, Interval> operator*() const {
return {{xVal, xVal + xDist},
{yVal, yVal + yDist}};
}
pair<Interval, Interval> operator->() const {
return {{xVal, xVal + xDist},
{yVal, yVal + yDist}};
}
};
};
#endif //INTERVAL_ANALYSIS_DOMAIN_H