Issue #77 Break dependency of sequence on propertyindex

This commit is contained in:
Mat Sutcliffe
2020-08-29 23:25:50 +01:00
parent 1c8fd1b47e
commit d1b6776c44
2 changed files with 0 additions and 29 deletions

View File

@@ -12,7 +12,6 @@
#define BLACKMISC_SEQUENCE_H
#include "blackmisc/containerbase.h"
#include "blackmisc/propertyindex.h"
#include "blackmisc/mixin/mixinicon.h"
#include <QVector>
#include <algorithm>
@@ -435,21 +434,6 @@ namespace BlackMisc
sort(BlackMisc::Predicates::MemberLess(key1, keys...));
}
//! In-place sort by some properties specified by a list of property indexes.
void sortByProperty(const CSequence<CPropertyIndex> &indexes)
{
sort([&indexes](const T &a, const T &b)
{
for (const auto &index : indexes)
{
int cmp = index.comparator()(a, b);
if (cmp < 0) { return true; }
if (cmp > 0) { return false; }
}
return false;
});
}
//! Return a copy sorted by a given comparator predicate.
template <class Predicate>
CSequence sorted(Predicate p) const
@@ -468,14 +452,6 @@ namespace BlackMisc
return sorted(BlackMisc::Predicates::MemberLess(key1, keys...));
}
//! Return a copy sorted by some properties specified by a list of property indexes.
CSequence sortedByProperty(const CSequence<CPropertyIndex> &indexes) const
{
CSequence result = *this;
result.sortByProperty(indexes);
return result;
}
//! In-place move the smallest n elements to the beginning and sort them.
template <class Predicate> void partiallySort(size_type n, Predicate p)
{

View File

@@ -74,8 +74,6 @@ namespace BlackMiscTest
QVERIFY(v3 == v33 && v3 == 0);
QVERIFY(callsigns.front().equalsString("DLH3000"));
callsigns.sortByProperty(indexListCs);
QVERIFY(callsigns.front().equalsString("DLH1000"));
CStatusMessage s1(CStatusMessage::SeverityDebug, u"debug msg.");
s1.setMSecsSinceEpoch(4000);
@@ -110,9 +108,6 @@ namespace BlackMiscTest
QVERIFY(msgs.front().getMSecsSinceEpoch() == 4000);
QVERIFY(msgs.back().getMSecsSinceEpoch() == 1000);
msgs.sortByProperty(indexList);
QVERIFY(msgs.front().getMSecsSinceEpoch() == 1000);
QVERIFY(msgs.back().getMSecsSinceEpoch() == 4000);
}
} // namespace