Ref T149, return number of removed elements

This commit is contained in:
Klaus Basan
2017-09-17 18:07:54 +02:00
committed by Mathew Sutcliffe
parent f8e672b04f
commit 815cf75f66
2 changed files with 9 additions and 9 deletions

View File

@@ -187,25 +187,25 @@ namespace BlackMisc
} }
template <class OBJ, class CONTAINER> template <class OBJ, class CONTAINER>
void ITimestampObjectList<OBJ, CONTAINER>::removeBefore(const QDateTime &dateTime) int ITimestampObjectList<OBJ, CONTAINER>::removeBefore(const QDateTime &dateTime)
{ {
this->removeBefore(dateTime.toMSecsSinceEpoch()); return this->removeBefore(dateTime.toMSecsSinceEpoch());
} }
template <class OBJ, class CONTAINER> template <class OBJ, class CONTAINER>
void ITimestampObjectList<OBJ, CONTAINER>::removeBefore(qint64 msSinceEpoc) int ITimestampObjectList<OBJ, CONTAINER>::removeBefore(qint64 msSinceEpoc)
{ {
this->container().removeIf([&](const OBJ & obj) return this->container().removeIf([&](const OBJ & obj)
{ {
return obj.isOlderThan(msSinceEpoc); return obj.isOlderThan(msSinceEpoc);
}); });
} }
template <class OBJ, class CONTAINER> template <class OBJ, class CONTAINER>
void ITimestampObjectList<OBJ, CONTAINER>::removeOlderThanNowMinusOffset(qint64 offsetMs) int ITimestampObjectList<OBJ, CONTAINER>::removeOlderThanNowMinusOffset(qint64 offsetMs)
{ {
const qint64 epoch = QDateTime::currentMSecsSinceEpoch() - offsetMs; const qint64 epoch = QDateTime::currentMSecsSinceEpoch() - offsetMs;
this->container().removeIf([&](const OBJ & obj) return this->container().removeIf([&](const OBJ & obj)
{ {
return obj.isOlderThan(epoch); return obj.isOlderThan(epoch);
}); });

View File

@@ -78,13 +78,13 @@ namespace BlackMisc
OBJ oldestObject() const; OBJ oldestObject() const;
//! Remove objects with timestamp before dateTime //! Remove objects with timestamp before dateTime
void removeBefore(const QDateTime &dateTime); int removeBefore(const QDateTime &dateTime);
//! Remove objects with timestamp before dateTime //! Remove objects with timestamp before dateTime
void removeBefore(qint64 msSinceEpoch); int removeBefore(qint64 msSinceEpoch);
//! Remove objects older than seconds //! Remove objects older than seconds
void removeOlderThanNowMinusOffset(qint64 offsetMs); int removeOlderThanNowMinusOffset(qint64 offsetMs);
//! Sort by timestamp //! Sort by timestamp
void sortLatestFirst(); void sortLatestFirst();