From 8ced68f619665709df606d0cd83663ed4ad70f8d Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Thu, 13 Dec 2018 22:28:13 +0100 Subject: [PATCH] added a method that copies dtaa from a std::map/QMap into the datastore --- lib/jkqtplotter/jkqtpdatastorage.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/jkqtplotter/jkqtpdatastorage.h b/lib/jkqtplotter/jkqtpdatastorage.h index 48db469be8..68443c4a06 100644 --- a/lib/jkqtplotter/jkqtpdatastorage.h +++ b/lib/jkqtplotter/jkqtpdatastorage.h @@ -473,6 +473,23 @@ class LIB_EXPORT JKQTPdatastore{ } + /** \brief copies the contents of the map-like container \a c into two columns of the datastore, + * returns the two IDs of the items as a std::pair */ + template + std::pair addCopiedMap(const TContainer& c, const QString& nameKey=QString("map_key"), const QString& nameValue=QString("map_value")) { + std::vector xvals; + std::vector yvals; + for (auto it=c.begin(); it!=c.end(); ++it) { + xvals.push_back(jkqtp_todouble(it->first)); + yvals.push_back(jkqtp_todouble(it->second)); + } + return std::make_pair( + addCopiedColumn(xvals, nameKey), + addCopiedColumn(yvals, nameValue) + ); + } + +