PtrListDetailI.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) 2018-2021 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
26\*---------------------------------------------------------------------------*/
27
28// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
29
30template<class T>
32:
33 List<T*>()
34{}
35
36
37template<class T>
39:
40 List<T*>(len, reinterpret_cast<T*>(0))
41{}
42
43
44template<class T>
46(
47 const UList<T*>& list
48)
49:
50 List<T*>(list)
51{}
52
53
54template<class T>
56(
57 const PtrListDetail<T>& list
58)
59:
60 List<T*>(list)
61{}
62
63
64template<class T>
66(
67 PtrListDetail<T>&& list
68)
69:
70 List<T*>(std::move(list))
71{}
72
74template<class T>
76(
78 bool reuse
79)
81 List<T*>(list, reuse)
82{}
84
85// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
87template<class T>
89(
90 const label n
91) noexcept
92{
94}
95
96
97template<class T>
98inline void Foam::Detail::PtrListDetail<T>::resize(const label newLen)
99{
100 if (newLen <= 0)
101 {
103 }
104 else if (newLen != List<T*>::size())
105 {
106 // Truncate or extend. Any new elements are initialized to nullptr.
107 List<T*>::resize(newLen, reinterpret_cast<T*>(0));
108 }
109}
110
111
112template<class T>
114{
115 const label idx = this->findNull();
117 if (idx >= 0)
118 {
120 << "Element " << idx << " is null" << nl
121 << abort(FatalError);
122 }
123}
124
126// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
127
128template<class T>
130(
131 const PtrListDetail<T>& list
132)
133{
134 List<T*>::operator=(list); // shallow copy
135}
136
137
138template<class T>
140(
141 PtrListDetail<T>&& list
142)
143{
144 List<T*>::transfer(list);
145}
146
147
148// ************************************************************************* //
label n
A rudimentary list of pointers used for PtrList, UPtrList, etc. This class is considered implementati...
Definition: PtrListDetail.H:64
void checkNonNull() const
FatalError if any null exists in the list.
constexpr PtrListDetail() noexcept
Default construct.
void setAddressableSize(const label n) noexcept
Set addressed size to be inconsistent with allocated storage.
virtual bool resize()
Resize the ODE solver.
Definition: Euler.C:53
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
void operator=(const UList< T > &a)
Assignment to UList operator. Takes linear time.
Definition: List.C:480
void clear()
Clear the list, i.e. set size to zero.
Definition: ListI.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 setAddressableSize(const label n) noexcept
Set addressed size to be inconsistent with allocated storage.
Definition: UListI.H:413
const volScalarField & T
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53