Ref T464 Implement removal of one sequence from another in O(n),

assuming that elements in both sequences are in the same order in both.
This commit is contained in:
Mat Sutcliffe
2018-12-11 17:12:09 +00:00
committed by Klaus Basan
parent 40ae7174a7
commit 71de01065b
4 changed files with 47 additions and 4 deletions

View File

@@ -65,6 +65,7 @@ namespace BlackMiscTest
void joinAndSplit();
void findTests();
void sortTests();
void removeTests();
void dictionaryBasics();
void timestampList();
void offsetTimestampList();
@@ -199,6 +200,23 @@ namespace BlackMiscTest
QVERIFY2(list.sortedBy(&Person::getAge, &Person::getName) == sorted, "sort by multiple members");
}
void CTestContainers::removeTests()
{
const CSequence<int> base { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
const CSequence<CSequence<int>> subsets
{
{}, { 1 }, { 9 }, { 5 }, { 1, 9 }, { 1, 5 }, { 5, 9 }, { 1, 2 },
{ 8, 9 }, { 4, 5, 6 }, { 1, 5, 9 }, { 3, 7 }, { 3, 5, 7 }, base
};
for (const auto &subset : subsets)
{
auto copy1 = base, copy2 = base;
copy1.removeIfIn(subset);
copy2.removeIfInSubset(subset);
QVERIFY2(copy1 == copy2, "removeIfInSubset");
}
}
void CTestContainers::dictionaryBasics()
{
CTestValueObject key1("Key1", "This is key object 1");