gtsam
Loading...
Searching...
No Matches
gtsam::DiscreteValues Class Reference

Detailed Description

A map from keys to values.

Inheritance diagram for gtsam::DiscreteValues:

Wrapper support

using Names = std::map<Key, std::vector<std::string>>
 Translation table from values to strings.
std::string markdown (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const
 Output as a markdown table.
std::string html (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const
 Output as a html table.
static std::string Translate (const Names &names, Key key, size_t index)
 Translate an integer index value for given key to a string.

Standard Interface

std::pair< iterator, bool > insert (const value_type &value)
DiscreteValues & insert (const std::pair< Key, size_t > &assignment)
 Insert key-assignment pair.
DiscreteValues & insert (const DiscreteValues &values)
 Insert all values from another DiscreteValues object.
DiscreteValues & update (const DiscreteValues &values)
 Update values with corresponding keys from another DiscreteValues object.
DiscreteValues & insert_or_assign (const DiscreteValues &values)
 Insert each element of values if it does not already exist, else assign it.
bool contains (Key key) const
 Check if the DiscreteValues contains the given key.
DiscreteValues filter (const DiscreteKeys &keys) const
 Filter values by keys.
DiscreteKeys missingKeys (const DiscreteKeys &keys) const
 Return the keys that are not present in the DiscreteValues object.
std::ostream & operator<< (std::ostream &os, const DiscreteValues &x)
 ostream operator:
static std::vector< DiscreteValues > CartesianProduct (const DiscreteKeys &keys)
 Return a vector of DiscreteValues, one for each possible combination of values.

Public Member Functions

Standard Constructors
 DiscreteValues (const Base &a)
 DiscreteValues (std::initializer_list< std::pair< const Key, size_t > > init)
 Assignment ()=default
 Assignment (std::initializer_list< std::pair< const L, size_t > > init)
Testable
void print (const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
 print required by Testable.
bool equals (const DiscreteValues &x, double tol=1e-9) const
 equals required by Testable for unit testing.
Public Member Functions inherited from gtsam::Assignment< Key >
 Assignment (std::initializer_list< std::pair< const Key, size_t > > init)
void print (const std::string &s="Assignment: ", const std::function< std::string(Key)> &labelFormatter=&DefaultFormatter) const
bool equals (const Assignment &other, double tol=1e-9) const

Public Types

using Base = Assignment<Key>

Additional Inherited Members

Static Public Member Functions inherited from gtsam::Assignment< Key >
static std::vector< AssignmentType > CartesianProduct (const std::vector< std::pair< Key, size_t > > &keys)
 Get Cartesian product consisting all possible configurations.

Member Function Documentation

◆ CartesianProduct()

std::vector< DiscreteValues > gtsam::DiscreteValues::CartesianProduct ( const DiscreteKeys & keys)
inlinestatic

Return a vector of DiscreteValues, one for each possible combination of values.

Parameters
keysThe keys to generate the Cartesian product for.
Returns
std::vector<DiscreteValues> The vector of DiscreteValues.

◆ contains()

bool gtsam::DiscreteValues::contains ( Key key) const
inline

Check if the DiscreteValues contains the given key.

Parameters
keyThe key to check for.
Returns
True if the key is present, false otherwise.

◆ filter()

DiscreteValues gtsam::DiscreteValues::filter ( const DiscreteKeys & keys) const
inline

Filter values by keys.

Parameters
keysThe keys to filter by.
Returns
DiscreteValues The filtered DiscreteValues object.

◆ html()

string DiscreteValues::html ( const KeyFormatter & keyFormatter = DefaultKeyFormatter,
const Names & names = {} ) const

Output as a html table.

Parameters
keyFormatterfunction that formats keys.
namestranslation table for values.
Returns
string html output.

◆ insert() [1/2]

DiscreteValues & DiscreteValues::insert ( const DiscreteValues & values)

Insert all values from another DiscreteValues object.

Parameters
valuesThe DiscreteValues object containing values to insert.
Returns
DiscreteValues& Reference to the updated DiscreteValues object.
Exceptions
std::invalid_argumentif any keys to be inserted are already used.

◆ insert() [2/2]

DiscreteValues & DiscreteValues::insert ( const std::pair< Key, size_t > & assignment)

Insert key-assignment pair.

Parameters
assignmentThe key-assignment pair to insert.
Returns
DiscreteValues& Reference to the updated DiscreteValues object.
Exceptions
std::invalid_argumentif any keys to be inserted are already used.

◆ insert_or_assign()

DiscreteValues & DiscreteValues::insert_or_assign ( const DiscreteValues & values)

Insert each element of values if it does not already exist, else assign it.

Parameters
valuesDiscreteValues to insert or assign to this.
Returns
DiscreteValues&

◆ markdown()

string DiscreteValues::markdown ( const KeyFormatter & keyFormatter = DefaultKeyFormatter,
const Names & names = {} ) const

Output as a markdown table.

Parameters
keyFormatterfunction that formats keys.
namestranslation table for values.
Returns
string markdown output.

◆ missingKeys()

DiscreteKeys gtsam::DiscreteValues::missingKeys ( const DiscreteKeys & keys) const
inline

Return the keys that are not present in the DiscreteValues object.

Parameters
keysThe keys to check for.
Returns
DiscreteKeys Keys not present in the DiscreteValues object.

◆ update()

DiscreteValues & DiscreteValues::update ( const DiscreteValues & values)

Update values with corresponding keys from another DiscreteValues object.

Parameters
valuesThe DiscreteValues object containing values to update.
Returns
DiscreteValues& Reference to the updated DiscreteValues object.
Exceptions
std::out_of_rangeif any keys in values are not present in this object.

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