bool BloombergVector::SetVector(const QList<QDate>& Dates, const QList<double>& Values) { Q_D(BloombergVector); if ( Dates.size() != Values.size() //Each date has a value and vice versa || Values.isEmpty() //The vectors are not empty || Dates.toSet().size()!=Dates.size() //There are no duplicates in the dates ) return false; QMap<QDate, double> SortedValues; for (int i = 0; i <Dates.size(); i++) { if (Dates.at(i).isNull()) return false; if (Values.at(i)<0.0) return false; SortedValues.insert(Dates.at(i), Values.at(i)); } d->m_AnchorDate = SortedValues.firstKey(); d->m_VectVal.clear(); int NumMonths; for (auto i = SortedValues.constBegin()+1; i != SortedValues.constEnd(); i++) { NumMonths = MonthDiff(i.key(), (i - 1).key()); for (int j = 0; j < NumMonths; j++) d->m_VectVal.append((i - 1).value()); } d->m_VectVal.append(SortedValues.last()); RepackVector(); return true; }