1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 \*---------------------------------------------------------------------------*/
28 #include "SortableList.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 int main(int argc, char *argv[])
51 sortedOrder(a, order);
53 Info<< "unsorted: " << a << endl;
55 Info<< "sorted: " << a << endl;
56 Info<< "indices: " << order << endl;
58 SortableList<label> b(orig);
59 Info<< "unsorted: " << orig << endl;
60 Info<< "sorted: " << b << endl;
61 Info<< "indices: " << b.indices() << endl;
63 Info<< "shrunk: " << b.shrink() << endl;
64 Info<< "indices: " << b.indices() << endl;
66 // repeat by assignment
68 Info<< "unsorted: " << b << endl;
71 Info<< "sorted: " << b << endl;
72 Info<< "indices: " << b.indices() << endl;
74 // find unique/duplicate values
77 Info<< "unsorted: " << b << endl;
78 uniqueOrder(b, order);
79 Info<< "unique: " << order << endl;
80 duplicateOrder(b, order);
81 Info<< "duplicate:" << order << endl;
84 Info<< "unsorted: " << b << endl;
86 Info<< "rsort: " << b << endl;
87 Info<< "indices: " << b.indices() << endl;
89 // transfer assignment
92 Info<< "unsorted: " << b << endl;
95 Info<< "sorted: " << b << endl;
96 Info<< "indices: " << b.indices() << endl;
100 Info<< "plain: " << a << endl;
101 Info<< "sorted: " << b << endl;
102 Info<< "indices: " << b.indices() << endl;
104 // sort/duplicate/unique with identical values
108 Info<< "unsorted: " << b << endl;
110 uniqueOrder(b, order);
111 Info<< "unique: " << order << endl;
112 duplicateOrder(b, order);
113 Info<< "duplicate:" << order << endl;
116 Info<< "sorted: " << b << endl;
117 Info<< "indices: " << b.indices() << endl;
119 // with a single value
122 Info<< "unsorted: " << b << endl;
123 uniqueOrder(b, order);
124 Info<< "unique: " << order << endl;
125 duplicateOrder(b, order);
126 Info<< "duplicate:" << order << endl;
129 Info<< "sorted: " << b << endl;
130 Info<< "indices: " << b.indices() << endl;
132 Info<< "\nEnd\n" << endl;
138 // ************************************************************************* //