LPtrList.C
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 OpenFOAM Foundation
9 Copyright (C) 2022 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 "LPtrList.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33template<class LListBase, class T>
34Foam::LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& lst)
35:
36 LList<LListBase, T*>()
37{
38 for (auto iter = lst.cbegin(); iter != lst.cend(); ++iter)
39 {
40 this->append((*iter).clone().ptr());
41 }
42}
43
44
45template<class LListBase, class T>
46Foam::LPtrList<LListBase, T>::LPtrList(LPtrList<LListBase, T>&& lst)
47:
48 LList<LListBase, T*>()
49{
51}
52
53
54// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
55
56template<class LListBase, class T>
58{
59 this->clear();
60}
61
62
63// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64
65template<class LListBase, class T>
67{
68 T* p = this->removeHead();
69 delete p;
70 return bool(p);
71}
72
73
74template<class LListBase, class T>
76{
77 label len = this->size();
78
79 while (len--)
80 {
81 eraseHead();
82 }
83
85}
86
87
88template<class LListBase, class T>
90{
91 clear();
93}
94
95
96// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
97
98template<class LListBase, class T>
100{
101 clear();
102
103 for (auto iter = lst.cbegin(); iter != lst.cend(); ++iter)
104 {
105 this->append((*iter).clone().ptr());
106 }
107}
108
109
110template<class LListBase, class T>
112{
113 transfer(lst);
114}
115
116
117// ************************************************************************* //
Template class for non-intrusive linked lists.
Definition: LList.H:79
void clear()
Delete contents of list.
Definition: LList.C:78
void append(const T * &elem)
Add copy at back of list.
Definition: LList.H:245
Template class for non-intrusive linked PtrLists.
Definition: LPtrList.H:75
const_iterator cbegin() const
Iterator to first item in list with const access.
Definition: LPtrList.H:350
bool eraseHead()
Remove the head element from the list and delete the pointer.
Definition: LPtrList.C:66
const const_iterator & cend() const
End of list for forward iterators.
Definition: LPtrList.H:387
void operator=(const LPtrList< LListBase, T > &lst)
Copy assign by using 'clone()' for each element.
Definition: LPtrList.C:99
void clear()
Clear the contents of the list.
Definition: LPtrList.C:75
LPtrList()=default
Default construct.
~LPtrList()
Destructor.
Definition: LPtrList.C:57
volScalarField & p
const volScalarField & T
bool
Definition: EEqn.H:20
patchWriters clear()
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))