1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 A list that is sorted upon construction or when explicitly requested
30 with the sort() method.
35 \*---------------------------------------------------------------------------*/
37 #ifndef SortableList_H
38 #define SortableList_H
40 #include "labelList.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 /*---------------------------------------------------------------------------*\
48 Class SortableList Declaration
49 \*---------------------------------------------------------------------------*/
66 //- Less function class used by the sort function
69 const UList<Type>& values_;
73 less(const UList<Type>& values)
78 bool operator()(const label a, const label b)
80 return values_[a] < values_[b];
87 //- Construct from List, sorting the elements. Starts with indices set
88 // to index in argument
89 explicit SortableList(const List<Type>&);
91 //- Construct given size. Sort later on.
92 explicit SortableList(const label size);
94 //- Construct given size and initial value. Sort later on.
95 SortableList(const label size, const Type&);
97 //- Construct as copy.
98 SortableList(const SortableList<Type>&);
103 //- Return the list of sorted indices. Updated every sort.
104 const labelList& indices() const
109 //- Size the list. If grow can cause undefined indices (until next sort)
110 void setSize(const label);
112 //- Sort the list (if changed after construction time)
115 //- Sort the list (if changed after construction time)
121 void operator=(const SortableList<Type>&);
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 } // End namespace Foam
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 # include "SortableList.C"
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 // ************************************************************************* //