From 7e2a940dfb2e0dee38065e19b43fd74df95e2cad Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 25 Nov 2008 11:52:38 +0100 Subject: [PATCH] SortableList + ListOps changes - dropped setSize() in favour of List::setSize(). The size of the indices is set in sort() anyhow and undefined before that. - added reverseSort() method - added ListOps uniqueOrder() and duplicateOrder() --- applications/test/sort/sortListTest.C | 99 ++++++++++++++----- .../containers/Lists/ListOps/ListOps.H | 7 ++ .../Lists/ListOps/ListOpsTemplates.C | 53 +++++++++- .../Lists/SortableList/SortableList.C | 61 ++++++++---- .../Lists/SortableList/SortableList.H | 16 ++- 5 files changed, 188 insertions(+), 48 deletions(-) diff --git a/applications/test/sort/sortListTest.C b/applications/test/sort/sortListTest.C index 34a756dae7..06d5b01186 100644 --- a/applications/test/sort/sortListTest.C +++ b/applications/test/sort/sortListTest.C @@ -27,6 +27,7 @@ Description \*---------------------------------------------------------------------------*/ #include "SortableList.H" +#include "ListOps.H" using namespace Foam; @@ -35,49 +36,101 @@ using namespace Foam; int main(int argc, char *argv[]) { - labelList orig(5); + labelList orig(8); orig[0] = 7; - orig[1] = 4; + orig[1] = 9; orig[2] = 1; orig[3] = 2; - orig[4] = 9; + orig[4] = 4; + orig[5] = 7; + orig[6] = 4; + orig[7] = 0; + + labelList order; labelList a(orig); - Info << "before: " << a << endl; + sortedOrder(a, order); + + Info<< "unsorted: " << a << endl; sort(a); - Info << "after: " << a << endl; + Info<< "sorted: " << a << endl; + Info<< "indices: " << order << endl; SortableList