Represents a set of variables.
This class is based on std::set<Variable>. The intent is to add things that we need including set-union (Variables::insert, operator+, operator+=), set-minus (Variables::erase, operator-, operator-=), and subset/superset checking functions (Variables::IsSubsetOf, Variables::IsSupersetOf, Variables::IsStrictSubsetOf, Variables::IsStrictSupersetOf).
#include <drake/common/symbolic/expression/variables.h>
Public Types | |
typedef std::set< Variable >::size_type | size_type |
typedef std::set< Variable >::iterator | iterator |
typedef std::set< Variable >::const_iterator | const_iterator |
typedef std::set< Variable >::reverse_iterator | reverse_iterator |
typedef std::set< Variable >::const_reverse_iterator | const_reverse_iterator |
Public Member Functions | |
Variables ()=default | |
Default constructor. More... | |
Variables (std::initializer_list< Variable > init) | |
List constructor. More... | |
Variables (const Eigen::Ref< const VectorX< Variable >> &vec) | |
Constructs from an Eigen vector of variables. More... | |
~Variables () | |
size_type | size () const |
Returns the number of elements. More... | |
bool | empty () const |
Checks if this set is empty or not. More... | |
std::string | to_string () const |
Returns string representation of Variables. More... | |
iterator | begin () |
Returns an iterator to the beginning. More... | |
iterator | end () |
Returns an iterator to the end. More... | |
const_iterator | begin () const |
Returns an iterator to the beginning. More... | |
const_iterator | end () const |
Returns an iterator to the end. More... | |
const_iterator | cbegin () const |
Returns a const iterator to the beginning. More... | |
const_iterator | cend () const |
Returns a const iterator to the end. More... | |
reverse_iterator | rbegin () |
Returns a reverse iterator to the beginning. More... | |
reverse_iterator | rend () |
Returns a reverse iterator to the end. More... | |
const_reverse_iterator | rbegin () const |
Returns a reverse iterator to the beginning. More... | |
const_reverse_iterator | rend () const |
Returns a reverse iterator to the end. More... | |
const_reverse_iterator | crbegin () const |
Returns a const reverse-iterator to the beginning. More... | |
const_reverse_iterator | crend () const |
Returns a const reverse-iterator to the end. More... | |
void | insert (const Variable &var) |
Inserts a variable var into a set. More... | |
template<class InputIt > | |
void | insert (InputIt first, InputIt last) |
Inserts variables in [first , last ) into a set. More... | |
void | insert (const Variables &vars) |
Inserts variables in vars into a set. More... | |
size_type | erase (const Variable &key) |
Erases key from a set. More... | |
size_type | erase (const Variables &vars) |
Erases variables in vars from a set. More... | |
iterator | find (const Variable &key) |
Finds element with specific key. More... | |
const_iterator | find (const Variable &key) const |
bool | include (const Variable &key) const |
Return true if key is included in the Variables. More... | |
bool | IsSubsetOf (const Variables &vars) const |
Return true if vars is a subset of the Variables. More... | |
bool | IsSupersetOf (const Variables &vars) const |
Return true if vars is a superset of the Variables. More... | |
bool | IsStrictSubsetOf (const Variables &vars) const |
Return true if vars is a strict subset of the Variables. More... | |
bool | IsStrictSupersetOf (const Variables &vars) const |
Return true if vars is a strict superset of the Variables. More... | |
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable | |
Variables (const Variables &)=default | |
Variables & | operator= (const Variables &)=default |
Variables (Variables &&)=default | |
Variables & | operator= (Variables &&)=default |
Friends | |
template<class HashAlgorithm > | |
void | hash_append (HashAlgorithm &hasher, const Variables &item) noexcept |
Implements the hash_append generic hashing concept. More... | |
bool | operator== (const Variables &vars1, const Variables &vars2) |
bool | operator< (const Variables &vars1, const Variables &vars2) |
std::ostream & | operator<< (std::ostream &, const Variables &vars) |
Variables | intersect (const Variables &vars1, const Variables &vars2) |
Returns the intersection of vars1 and vars2 . More... | |
typedef std::set<Variable>::const_iterator const_iterator |
typedef std::set<Variable>::const_reverse_iterator const_reverse_iterator |
typedef std::set<Variable>::reverse_iterator reverse_iterator |
|
default |
Default constructor.
Constructs from an Eigen vector of variables.
~Variables | ( | ) |
iterator begin | ( | ) |
Returns an iterator to the beginning.
const_iterator begin | ( | ) | const |
Returns an iterator to the beginning.
const_iterator cbegin | ( | ) | const |
Returns a const iterator to the beginning.
const_iterator cend | ( | ) | const |
Returns a const iterator to the end.
const_reverse_iterator crbegin | ( | ) | const |
Returns a const reverse-iterator to the beginning.
const_reverse_iterator crend | ( | ) | const |
Returns a const reverse-iterator to the end.
bool empty | ( | ) | const |
Checks if this set is empty or not.
iterator end | ( | ) |
Returns an iterator to the end.
const_iterator end | ( | ) | const |
Returns an iterator to the end.
Erases key
from a set.
Return number of erased elements (0 or 1).
Erases variables in vars
from a set.
Return number of erased elements ([0, vars.size()]).
const_iterator find | ( | const Variable & | key | ) | const |
void insert | ( | const Variable & | var | ) |
Inserts a variable var
into a set.
void insert | ( | InputIt | first, |
InputIt | last | ||
) |
Inserts variables in [first
, last
) into a set.
void insert | ( | const Variables & | vars | ) |
Inserts variables in vars
into a set.
bool IsStrictSubsetOf | ( | const Variables & | vars | ) | const |
Return true if vars
is a strict subset of the Variables.
bool IsStrictSupersetOf | ( | const Variables & | vars | ) | const |
Return true if vars
is a strict superset of the Variables.
bool IsSupersetOf | ( | const Variables & | vars | ) | const |
Return true if vars
is a superset of the Variables.
reverse_iterator rbegin | ( | ) |
Returns a reverse iterator to the beginning.
const_reverse_iterator rbegin | ( | ) | const |
Returns a reverse iterator to the beginning.
reverse_iterator rend | ( | ) |
Returns a reverse iterator to the end.
const_reverse_iterator rend | ( | ) | const |
Returns a reverse iterator to the end.
size_type size | ( | ) | const |
Returns the number of elements.
std::string to_string | ( | ) | const |
Returns string representation of Variables.
|
friend |
Implements the hash_append generic hashing concept.
Returns the intersection of vars1
and vars2
.
This function has a time complexity of O(N₁ + N₂)
where N₁
and N₂
are the size of vars1
and vars2
respectively.
|
friend |