SubListI.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2017-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "FixedList.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33template<class T>
35(
36 const UList<T>& list
37)
38:
39 UList<T>(const_cast<T*>(list.cdata()), list.size())
40{}
41
42
43template<class T>
44template<unsigned N>
46(
47 const FixedList<T, N>& list
48)
49:
50 UList<T>(const_cast<T*>(list.cdata()), static_cast<label>(N))
51{}
52
53
54template<class T>
56(
57 const UList<T>& list,
58 const label subSize
59)
60:
61 UList<T>(const_cast<T*>(list.cdata()), subSize)
62{
63 #ifdef FULLDEBUG
64 list.checkSize(subSize);
65 #endif
66}
67
68
69template<class T>
71(
72 const UList<T>& list,
73 const label subSize,
74 const label startIndex
75)
77 UList<T>(const_cast<T*>(list.cdata() + startIndex), subSize)
78{
79 #ifdef FULLDEBUG
80 list.checkRange(startIndex, subSize);
81 #endif
82}
83
84
85template<class T>
87(
88 const UList<T>& list,
89 const labelRange& range
90)
92 SubList<T>(range.subset0(list.size()), list)
93{
94 #ifdef FULLDEBUG
95 // The subset0() above always produces valid ranges but want to check
96 // that the input itself was valid
97 list.checkRange(range.start(), range.size());
98 #endif
99}
100
101
102template<class T>
104(
106 const UList<T>& list
107)
108:
109 SubList<T>(list, range.size(), range.start())
110{}
111
112
113// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114
115template<class T>
117{
118 return NullObjectRef<SubList<T>>();
119}
120
121
122// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
124template<class T>
126{
127 return *reinterpret_cast<const List<T>*>(this);
128}
129
130
131template<class T>
134 UList<T>::deepCopy(list);
135}
137
138template<class T>
139inline void Foam::SubList<T>::operator=(const UList<T>& list)
140{
141 UList<T>::deepCopy(list);
142}
144
145template<class T>
146template<class Addr>
148{
150}
151
152
153template<class T>
154inline void Foam::SubList<T>::operator=(const T& val)
155{
157}
158
159
160template<class T>
162{
164}
165
166
167// ************************************************************************* //
scalar range
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: FixedList.H:81
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
A List obtained as a section of another List.
Definition: SubList.H:70
void operator=(const SubList< T > &list)
Copy assign entries from given sub-list. Sizes must match!
Definition: SubListI.H:132
SubList() noexcept=default
Default construct, zero-sized and nullptr.
static const SubList< T > & null()
Return a null SubList.
Definition: SubListI.H:116
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
void checkSize(const label size) const
Check size is within valid range [0,size].
Definition: UListI.H:116
void checkRange(const label start, const label len) const
Check that start and length define a valid range.
Definition: UListI.H:130
A range or interval of labels defined by a start and a size.
Definition: labelRange.H:58
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:63
const volScalarField & T
const Vector< label > N(dict.get< Vector< label > >("N"))