ILList.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-2015 OpenFOAM Foundation
9  Copyright (C) 2017 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 "ILList.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class LListBase, class T>
35 :
36  UILList<LListBase, T>()
37 {
38  for (const auto& item : lst)
39  {
40  this->append(item.clone().ptr());
41  }
42 }
43 
44 
45 template<class LListBase, class T>
47 :
48  UILList<LListBase, T>()
49 {
50  LListBase::transfer(lst);
51 }
52 
53 
54 template<class LListBase, class T>
55 template<class CloneArg>
57 (
58  const ILList<LListBase, T>& lst,
59  const CloneArg& cloneArg
60 )
61 :
63 {
64  for (const auto& item :lst)
65  {
66  this->append(item.clone(cloneArg).ptr());
67  }
68 }
69 
70 
71 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
72 
73 template<class LListBase, class T>
75 {
76  this->clear();
77 }
78 
79 
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 
82 template<class LListBase, class T>
84 {
85  T* p = this->removeHead();
86 
87  if (p)
88  {
89  delete p;
90  return true;
91  }
92 
93  return false;
94 }
95 
96 template<class LListBase, class T>
98 {
99  T* p = remove(item);
100 
101  if (p)
102  {
103  delete p;
104  return true;
105  }
106 
107  return false;
108 }
109 
110 
111 template<class LListBase, class T>
113 {
114  const label len = this->size();
115 
116  for (label i=0; i<len; ++i)
117  {
118  eraseHead();
119  }
120 
122 }
123 
124 
125 template<class LListBase, class T>
127 {
128  clear();
129  LListBase::transfer(lst);
130 }
131 
132 
133 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
134 
135 template<class LListBase, class T>
137 {
138  this->clear();
139 
140  for (const auto& item : lst)
141  {
142  this->append(item.clone().ptr());
143  }
144 }
145 
146 
147 template<class LListBase, class T>
149 {
150  clear();
151  LListBase::transfer(lst);
152 }
153 
154 
155 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
ILList.H
Foam::ILList::eraseHead
bool eraseHead()
Remove the head element specified from the list and delete it.
Definition: ILList.C:83
append
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::ILList::clear
void clear()
Clear the contents of the list.
Definition: ILList.C:112
Foam::ILList
Template class for intrusive linked lists.
Definition: ILList.H:52
T
const volScalarField & T
Definition: createFieldRefs.H:2
Foam::ILList::ILList
ILList()=default
Default construct.
Foam::ILList::~ILList
~ILList()
Destructor.
Definition: ILList.C:74
clear
patchWriters clear()
Foam::ILList::erase
bool erase(T *item)
Remove the specified element from the list and delete it.
Definition: ILList.C:97
Foam::UILList
Template class for intrusive linked lists.
Definition: UILList.H:52
Foam::ILList::operator=
void operator=(const ILList< LListBase, T > &lst)
Copy assignment using the 'clone()' method for each element.
Definition: ILList.C:136
Foam::ILList::transfer
void transfer(ILList< LListBase, T > &lst)
Definition: ILList.C:126