IndirectSubList.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) 2020 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::IndirectSubList
28
29Description
30 Indirect access to a sub-section of a list.
31
32 In many cases, using a Foam::SubList provides a simpler and more
33 efficient means of accessing a sub-list.
34 There are, however, some advantages of a IndirectSubList:
35 - allows adjustment of its addressing range after construct
36 - can recover the original, underlying list at any time
37
38SeeAlso
39 Foam::SubList
40
41SourceFiles
42
43\*---------------------------------------------------------------------------*/
44
45#ifndef IndirectSubList_H
46#define IndirectSubList_H
47
49#include "IndirectListBase.H"
50#include "labelRange.H"
51
52// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53
54namespace Foam
55{
56
57/*---------------------------------------------------------------------------*\
58 Class IndirectSubList Declaration
59\*---------------------------------------------------------------------------*/
60
61template<class T>
63:
64 private IndirectListAddressing<labelRange>,
65 public IndirectListBase<T, labelRange>
66{
67public:
68
69 // Constructors
70
71 //- Construct from UList, the entire size
72 explicit IndirectSubList(const UList<T>& values)
73 :
76 (
77 values,
79 )
80 {}
81
82 //- Construct from values list and range
84 (
85 const UList<T>& values,
86 const labelRange& addr
87 )
88 :
91 (
92 values,
94 )
95 {}
96
97
98 // Member Functions
99
100 //- The list addressing
102
103
104 // Member Operators
105
106 //- Use standard assignment operations
107 using IndirectListBase<T, labelRange>::operator=;
108};
109
110
111// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112
113} // End namespace Foam
114
115// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116
117#endif
118
119// ************************************************************************* //
A class for storing list addressing (labels, slices etc), which are normally to used by IndirectList....
const Addr & addressing() const noexcept
Const access to the addressing.
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
const UList< T > & values() const noexcept
The list of values (without addressing)
label size() const noexcept
The number of elements in the list.
Indirect access to a sub-section of a list.
IndirectSubList(const UList< T > &values, const labelRange &addr)
Construct from values list and range.
const Addr & addressing() const noexcept
The list addressing.
IndirectSubList(const UList< T > &values)
Construct from UList, the entire size.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
A range or interval of labels defined by a start and a size.
Definition: labelRange.H:58
const volScalarField & T
Namespace for OpenFOAM.