Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
containers
Lists
SortableList
SortableList.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 | Copyright (C) 1991-2010 OpenCFD Ltd.
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
License
9
This file is part of OpenFOAM.
10
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.
15
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
19
for more details.
20
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/>.
23
24
Class
25
Foam::SortableList
26
27
Description
28
A list that is sorted upon construction or when explicitly requested
29
with the sort() method.
30
31
Uses the Foam::stableSort() algorithm.
32
33
SourceFiles
34
SortableList.C
35
36
\*---------------------------------------------------------------------------*/
37
38
#ifndef SortableList_H
39
#define SortableList_H
40
41
#include <
OpenFOAM/labelList.H
>
42
43
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44
45
namespace
Foam
46
{
47
48
/*---------------------------------------------------------------------------*\
49
Class SortableList Declaration
50
\*---------------------------------------------------------------------------*/
51
52
template
<
class
T>
53
class
SortableList
54
:
55
public
List
<T>
56
{
57
// Private data
58
59
//- Original indices
60
labelList
indices_;
61
62
//- Resize, fill and sort the parameter according to the list values
63
void
sortIndices(
List<label>
&)
const
;
64
65
public
:
66
67
// Constructors
68
69
//- Null constructor, sort later (eg, after assignment or transfer)
70
SortableList
();
71
72
//- Construct from UList, sorting immediately.
73
explicit
SortableList
(
const
UList<T>
&);
74
75
//- Construct from transferred List, sorting immediately.
76
explicit
SortableList
(
const
Xfer
<
List<T>
>&);
77
78
//- Construct given size. Sort later on.
79
// The indices remain empty until the list is sorted
80
explicit
SortableList
(
const
label
size
);
81
82
//- Construct given size and initial value. Sort later on.
83
// The indices remain empty until the list is sorted
84
SortableList
(
const
label size,
const
T
&);
85
86
//- Construct as copy.
87
SortableList
(
const
SortableList<T>
&);
88
89
90
// Member Functions
91
92
//- Return the list of sorted indices. Updated every sort.
93
const
labelList
&
indices
()
const
94
{
95
return
indices_;
96
}
97
98
//- Return non-const access to the sorted indices. Updated every sort.
99
labelList
&
indices
()
100
{
101
return
indices_;
102
}
103
104
//- Clear the list and the indices
105
void
clear
();
106
107
//- Clear the indices and return a reference to the underlying List
108
List<T>
&
shrink
();
109
110
//- (stable) sort the list (if changed after construction time)
111
// also resizes the indices as required
112
void
sort
();
113
114
//- Reverse (stable) sort the list
115
void
reverseSort
();
116
117
//- Transfer contents to the Xfer container as a plain List
118
inline
Xfer<List<T>
>
xfer
();
119
120
121
// Member Operators
122
123
//- Assignment of all entries to the given value
124
inline
void
operator=
(
const
T
&);
125
126
//- Assignment from UList operator. Takes linear time.
127
inline
void
operator=
(
const
UList<T>
&);
128
129
//- Assignment operator. Takes linear time.
130
inline
void
operator=
(
const
SortableList<T>
&);
131
132
};
133
134
135
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136
137
}
// End namespace Foam
138
139
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140
141
#ifdef NoRepository
142
# include <
OpenFOAM/SortableList.C
>
143
#endif
144
145
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146
147
#endif
148
149
// ************************ vim: set sw=4 sts=4 et: ************************ //