Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
IntegerInterval.h
Go to the documentation of this file.
1#pragma once
2
3#include <boost/optional.hpp>
4
5namespace storm {
6namespace storage {
8 public:
9 explicit IntegerInterval(int64_t v) : leftBound(v), rightBound(v) {}
10
11 IntegerInterval(int64_t lb, int64_t rb) : leftBound(lb), rightBound(rb) {}
12
13 bool hasLeftBound() const {
14 return leftBound != boost::none;
15 }
16
17 bool hasRightBound() const {
18 return rightBound != boost::none;
19 }
20
21 bool contains(int64_t val) const {
22 if (hasLeftBound()) {
23 if (val < leftBound.get()) {
24 return false;
25 }
26 }
27 if (hasRightBound()) {
28 if (val > rightBound.get()) {
29 return false;
30 }
31 }
32 return true;
33 }
34
35 bool contains(IntegerInterval const& i) const {
36 if (hasLeftBound()) {
37 if (!i.hasLeftBound()) {
38 return false;
39 }
40 if (leftBound.get() > i.getLeftBound().get()) {
41 return false;
42 }
43 }
44 if (hasRightBound()) {
45 if (!i.hasRightBound()) {
46 return false;
47 }
48 if (rightBound.get() < i.getRightBound().get()) {
49 return false;
50 }
51 }
52 return true;
53 }
54
55 void extend(int64_t val) {
56 if (hasLeftBound()) {
57 if (val < leftBound.get()) {
58 leftBound = val;
59 return;
60 }
61 }
62 if (hasRightBound()) {
63 if (val > rightBound.get()) {
64 rightBound = val;
65 }
66 }
67 }
68
69 void extend(IntegerInterval const& i) {
70 if (i.hasLeftBound()) {
71 extend(i.getLeftBound().get());
72 }
73 if (i.hasRightBound()) {
74 extend(i.getRightBound().get());
75 }
76 }
77
78 boost::optional<int64_t> getLeftBound() const {
79 return leftBound;
80 }
81
82 boost::optional<int64_t> getRightBound() const {
83 return rightBound;
84 }
85
86 private:
87 boost::optional<int64_t> leftBound;
88 boost::optional<int64_t> rightBound;
89};
90
91std::ostream& operator<<(std::ostream& os, IntegerInterval const& i);
92IntegerInterval parseIntegerInterval(std::string const& stringRepr);
93} // namespace storage
94} // namespace storm
void extend(IntegerInterval const &i)
boost::optional< int64_t > getRightBound() const
IntegerInterval(int64_t lb, int64_t rb)
bool contains(int64_t val) const
boost::optional< int64_t > getLeftBound() const
bool contains(IntegerInterval const &i) const
IntegerInterval parseIntegerInterval(std::string const &stringRepr)
std::ostream & operator<<(std::ostream &out, ParameterRegion< ParametricType > const &region)
LabParser.cpp.
Definition cli.cpp:18