ENH: add inplaceUniqueSort function

- determines a unique sort order (as per uniqueOrder) and uses that to
  reorder the list and possibly truncate it.
This commit is contained in:
Mark Olesen
2017-03-08 11:10:16 +01:00
parent b7dc6d0441
commit 3d3c14cbff
3 changed files with 57 additions and 5 deletions

View File

@ -113,9 +113,9 @@ int main(int argc, char *argv[])
Info<< nl << "Test lambda predicates:" << nl << endl;
List<label> test6(identity(19));
List<label> test6(identity(11));
// shift range for general testing
std::for_each(test6.begin(), test6.end(), [](label& x){ x -= 10; });
std::for_each(test6.begin(), test6.end(), [](label& x){ x -= 4; });
Info<< "Subset of non-zero, even values: "
<< subsetList
@ -125,6 +125,16 @@ int main(int argc, char *argv[])
) << nl
<< endl;
test6.append(identity(13));
// Randomize the list
std::random_shuffle(test6.begin(), test6.end());
Info<< "Randomized: " << flatOutput(test6) << endl;
inplaceUniqueSort(test6);
Info<< "Unique : " << flatOutput(test6) << endl;
Info<< "\nEnd\n" << endl;
return 0;