move DiscreteKeys code to .cpp

release/4.3a0
Varun Agrawal 2022-09-01 10:40:48 -04:00
parent c6ebbdc708
commit ab017dfd19
2 changed files with 24 additions and 19 deletions

View File

@ -48,4 +48,25 @@ namespace gtsam {
return keys & key2; return keys & key2;
} }
void DiscreteKeys::print(const std::string& s,
const KeyFormatter& keyFormatter) const {
for (auto&& dkey : *this) {
std::cout << DefaultKeyFormatter(dkey.first) << " " << dkey.second
<< std::endl;
}
}
bool DiscreteKeys::equals(const DiscreteKeys& other, double tol) const {
if (this->size() != other.size()) {
return false;
}
for (size_t i = 0; i < this->size(); i++) {
if (this->at(i).first != other.at(i).first ||
this->at(i).second != other.at(i).second) {
return false;
}
}
return true;
}
} }

View File

@ -73,26 +73,10 @@ namespace gtsam {
/// Print the keys and cardinalities. /// Print the keys and cardinalities.
void print(const std::string& s = "", void print(const std::string& s = "",
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const { const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
for (auto&& dkey : *this) {
std::cout << DefaultKeyFormatter(dkey.first) << " " << dkey.second
<< std::endl;
}
}
bool equals(const DiscreteKeys& other, double tol = 0) const { /// Check equality to another DiscreteKeys object.
if (this->size() != other.size()) { bool equals(const DiscreteKeys& other, double tol = 0) const;
return false;
}
for (size_t i = 0; i < this->size(); i++) {
if (this->at(i).first != other.at(i).first ||
this->at(i).second != other.at(i).second) {
return false;
}
}
return true;
}
/** Serialization function */ /** Serialization function */
friend class boost::serialization::access; friend class boost::serialization::access;