mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
refs #570 Removed unused method splitByTime.
This commit is contained in:
@@ -102,32 +102,6 @@ namespace BlackMisc
|
||||
return this->container().contains(&OBJ::hasValidTimestamp, false);
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER>
|
||||
QList<CONTAINER> ITimestampObjectList<OBJ, CONTAINER>::splitByTime(qint64 msSinceEpoch, bool sortedLatestFirst) const
|
||||
{
|
||||
QList<CONTAINER> result { {}, {} };
|
||||
const auto &c = this->container();
|
||||
if (sortedLatestFirst)
|
||||
{
|
||||
// O(log n) comparisons and O(n) copies
|
||||
struct Comparator
|
||||
{
|
||||
bool operator()(const OBJ &a, qint64 b) const { return a.isNewerThan(b); }
|
||||
bool operator()(qint64 a, const OBJ &b) const { return b.isOlderThan(a); }
|
||||
};
|
||||
auto it = std::upper_bound(c.begin(), c.end(), msSinceEpoch, Comparator());
|
||||
std::copy(c.begin(), it, std::back_inserter(result[0]));
|
||||
std::copy(it, c.end(), std::back_inserter(result[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
// O(n) comparisons and O(n) copies
|
||||
std::partition_copy(c.begin(), c.end(), std::back_inserter(result[0]), std::back_inserter(result[1]),
|
||||
[msSinceEpoch](const OBJ & obj) { return ! obj.isNewerThan(msSinceEpoch); });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER>
|
||||
QDateTime ITimestampObjectList<OBJ, CONTAINER>::latestTimestamp() const
|
||||
{
|
||||
|
||||
@@ -50,10 +50,6 @@ namespace BlackMisc
|
||||
//! Has invalid timestamp
|
||||
bool hasInvalidTimestamps() const;
|
||||
|
||||
//! Partition into two containers, first [0,msSinceEpoch] and second (msSinceEpoch,LLONG_MAX].
|
||||
//! Within each of the two parts, the original relative ordering of the elements is preserved.
|
||||
QList<CONTAINER> splitByTime(qint64 msSinceEpoch, bool sortedLatestFirst = false) const;
|
||||
|
||||
//! Latest timestamp
|
||||
QDateTime latestTimestamp() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user