Drake
Drake C++ Documentation
Variables Class Reference

Detailed Description

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
 
Variablesoperator= (const Variables &)=default
 
 Variables (Variables &&)=default
 
Variablesoperator= (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...
 

Member Typedef Documentation

◆ const_iterator

◆ const_reverse_iterator

◆ iterator

typedef std::set<Variable>::iterator iterator

◆ reverse_iterator

◆ size_type

typedef std::set<Variable>::size_type size_type

Constructor & Destructor Documentation

◆ Variables() [1/5]

Variables ( const Variables )
default

◆ Variables() [2/5]

Variables ( Variables &&  )
default

◆ Variables() [3/5]

Variables ( )
default

Default constructor.

◆ Variables() [4/5]

Variables ( std::initializer_list< Variable init)

List constructor.

◆ Variables() [5/5]

Variables ( const Eigen::Ref< const VectorX< Variable >> &  vec)
explicit

Constructs from an Eigen vector of variables.

◆ ~Variables()

~Variables ( )

Member Function Documentation

◆ begin() [1/2]

iterator begin ( )

Returns an iterator to the beginning.

◆ begin() [2/2]

const_iterator begin ( ) const

Returns an iterator to the beginning.

◆ cbegin()

const_iterator cbegin ( ) const

Returns a const iterator to the beginning.

◆ cend()

const_iterator cend ( ) const

Returns a const iterator to the end.

◆ crbegin()

const_reverse_iterator crbegin ( ) const

Returns a const reverse-iterator to the beginning.

◆ crend()

const_reverse_iterator crend ( ) const

Returns a const reverse-iterator to the end.

◆ empty()

bool empty ( ) const

Checks if this set is empty or not.

◆ end() [1/2]

iterator end ( )

Returns an iterator to the end.

◆ end() [2/2]

const_iterator end ( ) const

Returns an iterator to the end.

◆ erase() [1/2]

size_type erase ( const Variable key)

Erases key from a set.

Return number of erased elements (0 or 1).

◆ erase() [2/2]

size_type erase ( const Variables vars)

Erases variables in vars from a set.

Return number of erased elements ([0, vars.size()]).

◆ find() [1/2]

iterator find ( const Variable key)

Finds element with specific key.

◆ find() [2/2]

const_iterator find ( const Variable key) const

◆ include()

bool include ( const Variable key) const

Return true if key is included in the Variables.

◆ insert() [1/3]

void insert ( const Variable var)

Inserts a variable var into a set.

◆ insert() [2/3]

void insert ( InputIt  first,
InputIt  last 
)

Inserts variables in [first, last) into a set.

◆ insert() [3/3]

void insert ( const Variables vars)

Inserts variables in vars into a set.

◆ IsStrictSubsetOf()

bool IsStrictSubsetOf ( const Variables vars) const

Return true if vars is a strict subset of the Variables.

◆ IsStrictSupersetOf()

bool IsStrictSupersetOf ( const Variables vars) const

Return true if vars is a strict superset of the Variables.

◆ IsSubsetOf()

bool IsSubsetOf ( const Variables vars) const

Return true if vars is a subset of the Variables.

◆ IsSupersetOf()

bool IsSupersetOf ( const Variables vars) const

Return true if vars is a superset of the Variables.

◆ operator=() [1/2]

Variables& operator= ( Variables &&  )
default

◆ operator=() [2/2]

Variables& operator= ( const Variables )
default

◆ rbegin() [1/2]

reverse_iterator rbegin ( )

Returns a reverse iterator to the beginning.

◆ rbegin() [2/2]

const_reverse_iterator rbegin ( ) const

Returns a reverse iterator to the beginning.

◆ rend() [1/2]

reverse_iterator rend ( )

Returns a reverse iterator to the end.

◆ rend() [2/2]

const_reverse_iterator rend ( ) const

Returns a reverse iterator to the end.

◆ size()

size_type size ( ) const

Returns the number of elements.

◆ to_string()

std::string to_string ( ) const

Returns string representation of Variables.

Friends And Related Function Documentation

◆ hash_append

void hash_append ( HashAlgorithm &  hasher,
const Variables item 
)
friend

Implements the hash_append generic hashing concept.

◆ intersect

Variables intersect ( const Variables vars1,
const Variables vars2 
)
friend

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.

◆ operator<

bool operator< ( const Variables vars1,
const Variables vars2 
)
friend

◆ operator<<

std::ostream& operator<< ( std::ostream &  ,
const Variables vars 
)
friend

◆ operator==

bool operator== ( const Variables vars1,
const Variables vars2 
)
friend

The documentation for this class was generated from the following file: