From ae1634210b26afe3e843348ab0d19ba058cf3f40 2017-08-31 09:37:47 From: Alexandre Leroux Date: 2017-08-31 09:37:47 Subject: [PATCH] Updates merge() method (2) Adds methods to be compatible with std::set_union() --- diff --git a/core/include/Data/ArrayData.h b/core/include/Data/ArrayData.h index 92134dd..6a149e2 100644 --- a/core/include/Data/ArrayData.h +++ b/core/include/Data/ArrayData.h @@ -235,6 +235,17 @@ public: m_Data, m_NbComponents, false)}}; } + /// Inserts at the end of the array data the values passed as a parameter. This + /// method is intended to be used in the context of generating a back insert iterator, or only + /// if it's ensured that the total size of the vector is consistent with the number of + /// components of the array data + /// @param values the values to insert + /// @sa http://en.cppreference.com/w/cpp/iterator/back_inserter + void push_back(const QVector &values) + { + Q_ASSERT(values.size() % m_NbComponents == 0); + m_Data.append(values); + } /** * @return the data at a specified index diff --git a/core/include/Data/DataSeries.h b/core/include/Data/DataSeries.h index 22c4a79..bfa12c9 100644 --- a/core/include/Data/DataSeries.h +++ b/core/include/Data/DataSeries.h @@ -91,6 +91,10 @@ class SCIQLOP_CORE_EXPORT DataSeries : public IDataSeries { friend class DataSeriesMergeHelper; public: + /// Tag needed to define the push_back() method + /// @sa push_back() + using value_type = DataSeriesIteratorValue; + /// @sa IDataSeries::xAxisData() std::shared_ptr > xAxisData() override { return m_XAxisData; } const std::shared_ptr > xAxisData() const { return m_XAxisData; } @@ -230,6 +234,22 @@ public: virtual void lockWrite() { m_Lock.lockForWrite(); } virtual void unlock() { m_Lock.unlock(); } + // ///// // + // Other // + // ///// // + + /// Inserts at the end of the data series the value of the iterator passed as a parameter. This + /// method is intended to be used in the context of generating a back insert iterator + /// @param iteratorValue the iterator value containing the values to insert + /// @sa http://en.cppreference.com/w/cpp/iterator/back_inserter + /// @sa merge() + /// @sa value_type + void push_back(const value_type &iteratorValue) + { + m_XAxisData->push_back(QVector{iteratorValue.x()}); + m_ValuesData->push_back(iteratorValue.values()); + } + protected: /// Protected ctor (DataSeries is abstract). The vectors must have the same size, otherwise a /// DataSeries with no values will be created.