! \overload Adds the provided points in \a keys and \a values to the current data. The provided vectors should have equal length. Else, the number of added points will be the size of the smallest vector. If you can guarantee that the passed data points are sorted by \a keys in ascending order, you can set \a alreadySorted to true, to improve performance by saving a sorting run.
| 21051 | returns a pointer to the internal data container. |
| 21052 | */ |
| 21053 | void QCPGraph::addData(const QVector<double> &keys, const QVector<double> &values, bool alreadySorted) |
| 21054 | { |
| 21055 | if (keys.size() != values.size()) |
| 21056 | qDebug() << Q_FUNC_INFO << "keys and values have different sizes:" << keys.size() << values.size(); |
| 21057 | const int n = qMin(keys.size(), values.size()); |
| 21058 | QVector<QCPGraphData> tempData(n); |
| 21059 | QVector<QCPGraphData>::iterator it = tempData.begin(); |
| 21060 | const QVector<QCPGraphData>::iterator itEnd = tempData.end(); |
| 21061 | int i = 0; |
| 21062 | while (it != itEnd) |
| 21063 | { |
| 21064 | it->key = keys[i]; |
| 21065 | it->value = values[i]; |
| 21066 | ++it; |
| 21067 | ++i; |
| 21068 | } |
| 21069 | mDataContainer->add(tempData, alreadySorted); // don't modify tempData beyond this to prevent copy on write |
| 21070 | } |
| 21071 | |
| 21072 | /*! \overload |
| 21073 |