3#include <initializer_list>
6#include <unordered_map>
8#include "dlinear/libs/libgmp.h"
9#include "dlinear/symbolic/symbolic_variable.h"
10#include "dlinear/symbolic/symbolic_variables.h"
12namespace dlinear::drake::symbolic {
59 typedef mpq_class mapped_type;
60 typedef typename std::unordered_map<key_type, mapped_type> map;
61 typedef typename std::unordered_map<key_type, double> double_map;
64 typedef typename map::iterator iterator;
65 typedef typename map::const_iterator const_iterator;
86 iterator
begin() {
return map_.begin(); }
88 iterator
end() {
return map_.end(); }
90 const_iterator
begin()
const {
return map_.cbegin(); }
92 const_iterator
end()
const {
return map_.cend(); }
94 const_iterator
cbegin()
const {
return map_.cbegin(); }
96 const_iterator
cend()
const {
return map_.cend(); }
99 std::pair<Environment::iterator, bool>
insert(
const key_type &key,
const mapped_type &elem);
101 bool empty()
const {
return map_.empty(); }
103 size_t size()
const {
return map_.size(); }
108 const_iterator
find(
const key_type &key)
const {
return map_.find(key); }
136 friend std::ostream &operator<<(std::ostream &os,
const Environment &env);
Represents a symbolic environment (mapping from a variable to a value).
std::string to_string() const
Returns string representation.
const mapped_type & at(const key_type &key) const
Returns the value that is mapped to a key equivalent to key.
iterator find(const key_type &key)
Finds element with specific key.
Variables domain() const
Returns the domain of this environment.
mapped_type & operator[](const key_type &key)
Returns a reference to the value that is mapped to a key equivalent to key, performing an insertion i...
const_iterator find(const key_type &key) const
Finds element with specific key.
const_iterator begin() const
Returns a const iterator to the beginning.
Environment(std::initializer_list< value_type > init)
List constructor.
const_iterator end() const
Returns a const iterator to the end.
const_iterator cbegin() const
Returns a const iterator to the beginning.
const mapped_type & operator[](const key_type &key) const
As above, but returns a constref and does not perform an insertion (throwing a runtime error instead)...
iterator end()
Returns an iterator to the end.
std::pair< Environment::iterator, bool > insert(const key_type &key, const mapped_type &elem)
Inserts a pair (key, elem).
const_iterator cend() const
Returns a const iterator to the end.
map::value_type value_type
std::pair<key_type, mapped_type>
Environment()=default
Default constructor.
~Environment()=default
Default destructor.
bool contains(const key_type &key) const
Checks whether the environment contains a variable key.
Environment(map m)
Constructs an environment from m.
size_t size() const
Returns the number of elements.
void erase(const iterator &pos)
Erases the element at the specified pos.
Environment(std::initializer_list< key_type > vars)
List constructor.
iterator begin()
Returns an iterator to the beginning.
bool empty() const
Checks whether the container is empty.
std::size_t erase(const key_type &key)
Erases the element with specific key.
Represents a symbolic variable.
Represents a set of variables.