dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
BoundIterator.h
1
10#pragma once
11
12#include <cstddef>
13#include <iosfwd>
14#include <iterator>
15#include <optional>
16#include <utility>
17#include <vector>
18
19#include "dlinear/solver/Bound.h"
20
21namespace dlinear {
22
44 public:
45 using vector_type = std::vector<Bound>;
46 using internal_iterator = typename vector_type::const_iterator;
47 using iterator_category = std::input_iterator_tag;
48 using value_type = typename vector_type::value_type;
49 using reference = value_type const &;
50 using pointer = value_type const *;
51 using difference_type = std::ptrdiff_t;
52
61 BoundIterator(internal_iterator begin_bounds_it, internal_iterator end_bounds_it);
67 explicit BoundIterator(std::pair<internal_iterator, internal_iterator> bounds);
77 BoundIterator(internal_iterator begin_bounds_it, internal_iterator end_bounds_it,
78 internal_iterator begin_nq_bounds_it, internal_iterator end_nq_bounds_it);
86 BoundIterator(std::pair<internal_iterator, internal_iterator> bounds,
87 std::pair<internal_iterator, internal_iterator> nq_bounds);
88
89 explicit operator bool() const { return bounds_it_ != end_bounds_it_ || nq_bounds_it_ != end_nq_bounds_it_; }
90
91 pointer operator->() const { return bounds_it_ != end_bounds_it_ ? &*bounds_it_ : &*nq_bounds_it_; }
92 reference operator*() const { return bounds_it_ != end_bounds_it_ ? *bounds_it_ : *nq_bounds_it_; }
93
94 BoundIterator &operator++();
95 const BoundIterator operator++(int);
96
97 BoundIterator &operator--();
98 const BoundIterator operator--(int);
99
100 value_type operator[](int i) const;
101
106 [[nodiscard]] std::pair<internal_iterator, internal_iterator> bounds() const { return {bounds_it_, end_bounds_it_}; }
111 [[nodiscard]] std::pair<internal_iterator, internal_iterator> nq_bounds() const {
113 }
118 [[nodiscard]] inline std::size_t bounds_size() const { return std::distance(bounds_it_, end_bounds_it_); }
123 [[nodiscard]] inline std::size_t nq_bounds_size() const { return std::distance(nq_bounds_it_, end_nq_bounds_it_); }
130 [[nodiscard]] inline bool bounds_empty() const { return bounds_it_ == end_bounds_it_; }
137 [[nodiscard]] inline bool nq_bounds_empty() const { return nq_bounds_it_ == end_nq_bounds_it_; }
144 [[nodiscard]] inline bool empty() const { return bounds_empty() && nq_bounds_empty(); }
150 [[nodiscard]] inline std::size_t size() const { return bounds_size() + nq_bounds_size(); }
151
153 [[nodiscard]] internal_iterator begin() const { return bounds_it_; }
155 [[nodiscard]] internal_iterator end() const { return end_nq_bounds_it_; }
156
163 [[nodiscard]] LiteralSet explanation() const;
181 [[nodiscard]] std::set<LiteralSet> explanations(const std::optional<Literal> &lit = {}) const;
192 void explanations(std::set<LiteralSet> &explanations, const std::optional<Literal> &lit = {}) const;
193
194 private:
195 static const vector_type default_empty_vector_;
196
197 const internal_iterator begin_bounds_it_;
198 internal_iterator bounds_it_;
199 const internal_iterator end_bounds_it_;
200
201 const internal_iterator begin_nq_bounds_it_;
202 internal_iterator nq_bounds_it_;
203 const internal_iterator end_nq_bounds_it_;
204};
205
206std::ostream &operator<<(std::ostream &os, const BoundIterator &violation);
207
208} // namespace dlinear
BoundIterator class.
bool bounds_empty() const
Check if the iterator does not point to any bound.
const internal_iterator end_nq_bounds_it_
End iterator of the non-equal bounds.
std::size_t size() const
Number of bounds of any kind included between the begin and end iterators.
internal_iterator nq_bounds_it_
Iterator to the current non-equal bound.
std::size_t bounds_size() const
Number of bounds included between the begin and end iterators.
std::size_t nq_bounds_size() const
Number of non-equal bounds included between the begin and end iterators.
std::pair< internal_iterator, internal_iterator > nq_bounds() const
Return the pair of iterators to the non-equal bounds.
std::pair< internal_iterator, internal_iterator > bounds() const
Return the pair of iterators to the bounds.
bool empty() const
Check if the iterator does not point to any bound.
LiteralSet explanation() const
Produce and explanation formed by all the theory literals present in the violation.
internal_iterator bounds_it_
Iterator to the current bound.
internal_iterator end() const
Get read-only access to the end iterator of the BoundIterator.
static const vector_type default_empty_vector_
Default empty vector. Used for default construction.
internal_iterator begin() const
Get read-only access to the begin iterator of the BoundIterator.
const internal_iterator begin_nq_bounds_it_
Begin iterator to the first non-equal bound.
BoundIterator()
Construct an empty iterator.
std::set< LiteralSet > explanations(const std::optional< Literal > &lit={}) const
Produce a set of explanations.
const internal_iterator end_bounds_it_
End iterator of the bounds.
const internal_iterator begin_bounds_it_
Begin iterator to the first bound.
bool nq_bounds_empty() const
Check if the iterator does not point to any non-equal bound.
Global namespace for the dlinear library.
std::set< Literal > LiteralSet
A set of literals.
Definition literal.h:28