refs #570 Removed unused method splitByTime.

This commit is contained in:
Mathew Sutcliffe
2016-06-06 21:59:20 +01:00
parent 8c80cc33b3
commit a5dfa1ef00
4 changed files with 0 additions and 78 deletions

View File

@@ -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
{

View File

@@ -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;