mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 19:35:33 +08:00
Ref T149, return number of removed elements
This commit is contained in:
committed by
Mathew Sutcliffe
parent
f8e672b04f
commit
815cf75f66
@@ -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);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user