SortableListDRGEP.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::SortableListDRGEP
28 
29 Description
30  A list that is sorted upon construction or when explicitly requested
31  with the sort() method.
32 
33 SourceFiles
34  SortableListDRGEP.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef SortableListDRGEP_H
39 #define SortableListDRGEP_H
40 
41 #include "labelList.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class SortableListDRGEP Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 template <class Type>
54 :
55  public List<Type>
56 {
57  // Private data
58 
59  //- Original indices
60  labelList indices_;
61 
62 
63 public:
64 
65  // Public classes
66 
67  //- Less function class used by the sort function
68  class less
69  {
70  const UList<Type>& values_;
71 
72  public:
73 
74  less(const UList<Type>& values)
75  :
76  values_(values)
77  {}
78 
79  bool operator()(const label a, const label b)
80  {
81  return values_[a] < values_[b];
82  }
83  };
84 
85 
86  // Constructors
87 
88  //- Construct from List, sorting the elements. Starts with indices set
89  // to index in argument
90  explicit SortableListDRGEP(const List<Type>&);
91 
92  //- Construct given size. Sort later on.
93  explicit SortableListDRGEP(const label size);
94 
95  //- Construct given size and initial value. Sort later on.
96  SortableListDRGEP(const label size, const Type&);
97 
98  //- Construct as copy.
100 
101 
102  // Member Functions
103 
104  //- Return the list of sorted indices. Updated every sort.
105  const labelList& indices() const
106  {
107  return indices_;
108  }
109 
110  //- Size the list. If grow can cause undefined indices (until next sort)
111  void setSize(const label);
112 
113  //- Sort the list (if changed after construction time)
114  void sort();
115 
116  //- Partial sort the list (if changed after construction time)
117  void partialSort(int M);
118 
119  //- Sort the list (if changed after construction time)
120  void stableSort();
121 
122 
123  // Member Operators
124 
125  void operator=(const SortableListDRGEP<Type>&);
126 
127 };
128 
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 } // End namespace Foam
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
136 #ifdef NoRepository
137  #include "SortableListDRGEP.C"
138 #endif
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 #endif
143 
144 // ************************************************************************* //
Foam::SortableListDRGEP::operator=
void operator=(const SortableListDRGEP< Type > &)
Definition: SortableListDRGEP.C:148
Foam::HashTableOps::values
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Definition: HashOps.H:149
Foam::SortableListDRGEP::less::operator()
bool operator()(const label a, const label b)
Definition: SortableListDRGEP.H:78
Foam::SortableListDRGEP::less::less
less(const UList< Type > &values)
Definition: SortableListDRGEP.H:73
Foam::SortableListDRGEP::indices
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
Definition: SortableListDRGEP.H:104
Foam::SortableListDRGEP::partialSort
void partialSort(int M)
Partial sort the list (if changed after construction time)
Definition: SortableListDRGEP.C:106
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
labelList.H
Foam::SortableListDRGEP
A list that is sorted upon construction or when explicitly requested with the sort() method.
Definition: SortableListDRGEP.H:52
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
SortableListDRGEP.C
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::SortableListDRGEP::stableSort
void stableSort()
Sort the list (if changed after construction time)
Definition: SortableListDRGEP.C:124
M
#define M(I)
Foam::UList< Type >
Foam::SortableListDRGEP::less
Less function class used by the sort function.
Definition: SortableListDRGEP.H:67
Foam::SortableListDRGEP::sort
void sort()
Sort the list (if changed after construction time)
Definition: SortableListDRGEP.C:85
Foam::SortableListDRGEP::setSize
void setSize(const label)
Size the list. If grow can cause undefined indices (until next sort)
Definition: SortableListDRGEP.C:77
Foam::SortableListDRGEP::SortableListDRGEP
SortableListDRGEP(const List< Type > &)
Construct from List, sorting the elements. Starts with indices set.
Definition: SortableListDRGEP.C:34