1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 List of paired values, with sorting capability
33 \*---------------------------------------------------------------------------*/
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 typedef List<Tuple2<label, label> > labelLabelList;
46 typedef List<Tuple2<label, scalar> > labelScalarList;
47 typedef List<Tuple2<scalar, label> > scalarLabelList;
48 typedef List<Tuple2<scalar, scalar> > scalarScalarList;
50 template<class type1, class type2>
51 bool lessFirst(Tuple2<type1, type2> t1, Tuple2<type1, type2> t2)
53 return (t1.first() < t2.first());
56 template<class type1, class type2>
57 bool lessFirstSecond(Tuple2<type1, type2> t1, Tuple2<type1, type2> t2)
61 (t1.first() < t2.first())
62 || ((t1.first() == t2.first()) && (t1.second() < t2.second()))
66 template<class type1, class type2>
67 bool lessSecond(Tuple2<type1, type2> t1, Tuple2<type1, type2> t2)
69 return (t1.second() < t2.second());
72 template<class type1, class type2>
73 bool lessSecondFirst(Tuple2<type1, type2> t1, Tuple2<type1, type2> t2)
77 (t2.first() < t1.first())
78 || ((t2.first() == t1.first()) && (t2.second() < t1.second()))
82 template<class type1, class type2>
83 void sortTuple2ListBy1st(List<Tuple2<type1, type2> >& t2l)
85 sort(t2l, lessFirst<type1, type2>);
88 template<class type1, class type2>
89 void sortTuple2ListBy2nd(List<Tuple2<type1, type2> >& t2l)
91 sort(t2l, lessSecond<type1, type2>);
94 template<class type1, class type2>
95 void sortTuple2ListBy1stThen2nd(List<Tuple2<type1, type2> >& t2l)
97 sort(t2l, lessFirstSecond<type1, type2>);
100 template<class type1, class type2>
101 void sortTuple2ListBy2ndThen1st(List<Tuple2<type1, type2> >& t2l)
103 sort(t2l, lessSecondFirst<type1, type2>);
106 } // End namespace Foam
108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112 // ************************************************************************* //