45 static std::string DefaultFormatter(
const L& x) {
52 using std::map<L, size_t>::operator=;
58 Assignment(std::initializer_list<std::pair<const L, size_t>> init)
59 : std::map<L, size_t>{init} {}
61 void print(
const std::string& s =
"Assignment: ",
62 const std::function<std::string(L)>& labelFormatter =
63 &DefaultFormatter)
const {
64 std::cout << s <<
": ";
65 for (
const typename Assignment::value_type& keyValue : *
this) {
66 std::cout <<
"(" << labelFormatter(keyValue.first) <<
", " 67 << keyValue.second <<
")";
69 std::cout << std::endl;
73 return (*
this == other);
88 template <
typename Derived = Assignment<L>>
89 static std::vector<Derived> CartesianProduct(
90 const std::vector<std::pair<L, size_t>>& keys) {
91 std::vector<Derived> allPossValues;
94 for (
const DiscreteKey& key : keys)
95 values[key.first] = 0;
97 allPossValues.push_back(values);
99 for (j = 0; j < keys.size(); j++) {
100 L idx = keys[j].first;
102 if (values[idx] < keys[j].second)
break;
106 if (j == keys.size())
break;
108 return allPossValues;
Definition: Testable.h:112
GTSAM_EXPORT void print(const Matrix &A, const std::string &s, std::ostream &stream)
Definition: Assignment.h:37
Definition: chartTesting.h:28
std::pair< Key, size_t > DiscreteKey
Definition: DiscreteKey.h:38