Loading...
Searching...
No Matches
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-2023 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
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
49:
50 UList<T>(const_cast<T*>(list.cdata()), list.size())
51{}
52
53
54template<class T>
56(
57 const UList<T>& list,
58 const label len
59)
60:
61 UList<T>(const_cast<T*>(list.cdata()), len)
62{
63 #ifdef FULLDEBUG
64 list.checkSize(len);
65 #endif
66}
67
68
69template<class T>
71(
72 const UList<T>& list,
73 const label len,
74 const label start
75)
76:
77 UList<T>(const_cast<T*>(list.cdata() + start), len)
78{
79 #ifdef FULLDEBUG
80 list.checkRange(start, len);
81 #endif
82}
83
84
85template<class T>
87(
88 const UList<T>& list,
89 const labelRange& range
90)
91:
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(
105 const labelRange& range,
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>
116inline Foam::UList<T>& Foam::SubList<T>::reset(std::nullptr_t) noexcept
118 UList<T>::shallowCopy(nullptr);
119 return *this;
120}
121
122
123template<class T>
125(
126 const UList<T>& list
127) noexcept
130 return *this;
131}
132
133
134template<class T>
136(
137 const UList<T>& list,
138 const label len
139)
140{
141 #ifdef FULLDEBUG
142 list.checkSize(len);
143 #endif
145 UList<T>::shallowCopy(const_cast<T*>(list.cdata()), len);
146 return *this;
147}
148
150template<class T>
152(
153 const UList<T>& list,
154 const label len,
155 const label start
156)
157{
158 #ifdef FULLDEBUG
159 list.checkRange(start, len);
160 #endif
161
163 (
164 const_cast<T*>(list.cdata() + start),
165 len
166 );
167 return *this;
168}
169
170
171template<class T>
173(
174 const UList<T>& list,
175 const labelRange& range
176)
177{
178 #ifdef FULLDEBUG
179 // subset0() always produces valid ranges but want to check
180 // that the input itself was valid
181 list.checkRange(range.start(), range.size());
182 #endif
183
184 labelRange clamped(range.subset0(list.size()));
185
187 (
188 const_cast<T*>(list.cdata() + clamped.start()),
189 clamped.size()
190 );
191 return *this;
192}
193
194
195template<class T>
197(
198 const labelRange& range,
199 const UList<T>& list
200)
201{
202 #ifdef FULLDEBUG
203 list.checkRange(range.start(), range.size());
204 #endif
205
207 (
208 const_cast<T*>(list.cdata() + range.start()),
209 range.size()
210 );
211 return *this;
212}
214
215// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
216
217template<class T>
219{
220 UList<T>::deepCopy(list);
221}
222
223
224template<class T>
225inline void Foam::SubList<T>::operator=(const UList<T>& list)
227 UList<T>::deepCopy(list);
228}
229
230
231template<class T>
232template<class Addr>
237
238
239template<class T>
240inline void Foam::SubList<T>::operator=(const T& val)
241{
243}
244
245
246template<class T>
248{
250}
251
252
253// ************************************************************************* //
scalar range
A 1D vector of objects of type <T> with a fixed length <N>.
Definition FixedList.H:73
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
IntType start() const noexcept
The (inclusive) lower value of the range.
Definition IntRange.H:218
IntType size() const noexcept
The size of the range.
Definition IntRange.H:208
A non-owning sub-view of a List (allocated or unallocated storage).
Definition SubList.H:61
void operator=(const SubList< T > &list)
Copy assign entries (deep copy) from given sub-list. Sizes must match!
Definition SubListI.H:211
UList< T > & reset(std::nullptr_t) noexcept
Reset to zero-sized and nullptr.
Definition SubListI.H:109
SubList() noexcept=default
Default construct, zero-sized and nullptr.
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:89
void shallowCopy(T *__restrict__ ptr, const label len) noexcept
Copy the pointer and size.
Definition UListI.H:318
void deepCopy(const UList< T > &list)
Copy elements of the given UList. Sizes must match!
Definition UList.C:95
UList(const UList< T > &) noexcept=default
Copy construct, shallow copy.
const T * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
Definition UListI.H:267
void checkSize(const label size) const
Check size is within valid range [0,size].
Definition UListI.H:155
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
void checkRange(const label start, const label len) const
Check that start and length define a valid range.
Definition UListI.H:169
UList< T > & operator=(const UList< T > &)=delete
No copy assignment (default: shallow copy).
A range or interval of labels defined by a start and a size.
Definition labelRange.H:66
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
const direction noexcept
Definition scalarImpl.H:265
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)