Added keyformatter for VariableIndex::print()

release/4.3a0
Alex Cunningham 2013-11-08 16:28:42 +00:00
parent 8ee0342f7a
commit a95ade1f88
2 changed files with 4 additions and 3 deletions

View File

@ -30,11 +30,11 @@ bool VariableIndex::equals(const VariableIndex& other, double tol) const {
}
/* ************************************************************************* */
void VariableIndex::print(const string& str) const {
void VariableIndex::print(const string& str, const KeyFormatter& keyFormatter) const {
cout << str;
cout << "nEntries = " << nEntries() << ", nFactors = " << nFactors() << "\n";
BOOST_FOREACH(KeyMap::value_type key_factors, index_) {
cout << "var " << key_factors.first << ":";
cout << "var " << keyFormatter(key_factors.first) << ":";
BOOST_FOREACH(const size_t factor, key_factors.second)
cout << " " << factor;
cout << "\n";

View File

@ -106,7 +106,8 @@ public:
bool equals(const VariableIndex& other, double tol=0.0) const;
/** Print the variable index (for unit tests and debugging). */
void print(const std::string& str = "VariableIndex: ") const;
void print(const std::string& str = "VariableIndex: ",
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
/**
* Output dual hypergraph to Metis file format for use with hmetis