void clear ();
/**
- * Read or write the data of this object to or from a stream for the purpose
- * of serialization.
- */
+ * Remove all values added at the current row. This is useful when,
+ * for example, a time-step is rejected and all data recorded about
+ * it needs to be discarded.
+ */
+ void clear_current_row ();
+
+ /**
+ * Read or write the data of this object to or from a stream for the purpose
+ * of serialization.
+ */
template <class Archive>
void serialize(Archive &ar, const unsigned int version);
}
+void TableHandler::clear_current_row ()
+{
+ // Figure out what is the currect (max) length of the columns
+ // so that we "shave" one off.
+ unsigned long n = 0;
+ for (std::map< std::string, Column >::iterator p = columns.begin(); p != columns.end(); ++p)
+ n = std::max(n, p->second.entries.size());
+
+ // shave the top most element
+ if (n != 0)
+ for (std::map< std::string, Column >::iterator p = columns.begin(); p != columns.end(); ++p)
+ if (p->second.entries.size() == n)
+ p->second.entries.pop_back();
+}
+
+
DEAL_II_NAMESPACE_CLOSE
// now again fill row 4 partially
table.add_value(keys[0], 1);
+ // now clear the partial row above
+ table.clear_current_row();
+
// produce output. hope that row 4 is
// completely padded
table.write_text(deallog.get_file_stream(),
TableHandler::org_mode_table);
+
+ // now again fill row 4 partially
+ table.add_value(keys[0], 1);
+
+ // produce output. hope that we get 3 rows
+ table.write_text(deallog.get_file_stream(),
+ TableHandler::org_mode_table);
+
}
| key1 | key2 | key3 |
-| 0 | 0 | "" |
-| 1 | 0 | "" |
-| 2 | 113 | a |
-| 1 | 0 | "" |
+| 0 | 0 | "" |
+| 1 | 0 | "" |
+| 2 | 113 | a |
+| key1 | key2 | key3 |
+| 0 | 0 | "" |
+| 1 | 0 | "" |
+| 2 | 113 | a |
+| 1 | 0 | "" |