ILList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "ILList.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class LListBase, class T>
32 {
33  for
34  (
35  typename UILList<LListBase, T>::const_iterator iter = lst.begin();
36  iter != lst.end();
37  ++iter
38  )
39  {
40  this->append(iter().clone().ptr());
41  }
42 }
43 
44 
45 template<class LListBase, class T>
47 {
48  transfer(lst);
49 }
50 
51 
52 template<class LListBase, class T>
53 template<class CloneArg>
55 (
56  const ILList<LListBase, T>& lst,
57  const CloneArg& cloneArg
58 )
59 :
61 {
62  for
63  (
64  typename UILList<LListBase, T>::const_iterator iter = lst.begin();
65  iter != lst.end();
66  ++iter
67  )
68  {
69  this->append(iter().clone(cloneArg).ptr());
70  }
71 }
72 
73 
74 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
75 
76 template<class LListBase, class T>
78 {
79  this->clear();
80 }
81 
82 
83 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
84 
85 template<class LListBase, class T>
87 {
88  T* tPtr;
89  if ((tPtr = this->removeHead()))
90  {
91  delete tPtr;
92  return true;
93  }
94  else
95  {
96  return false;
97  }
98 }
99 
100 template<class LListBase, class T>
102 {
103  T* tPtr;
104  if ((tPtr = remove(p)))
105  {
106  delete tPtr;
107  return true;
108  }
109  else
110  {
111  return false;
112  }
113 }
114 
115 
116 template<class LListBase, class T>
118 {
119  label oldSize = this->size();
120  for (label i=0; i<oldSize; ++i)
121  {
122  eraseHead();
123  }
124 
126 }
127 
128 
129 template<class LListBase, class T>
131 {
132  clear();
133  LListBase::transfer(lst);
134 }
135 
136 
137 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
138 
139 template<class LListBase, class T>
141 {
142  this->clear();
143 
144  for
145  (
146  typename UILList<LListBase, T>::const_iterator iter = lst.begin();
147  iter != lst.end();
148  ++iter
149  )
150  {
151  this->append(iter().clone().ptr());
152  }
153 }
154 
155 
156 template<class LListBase, class T>
158 {
159  transfer(lst);
160 }
161 
162 
163 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
164 
165 #include "ILListIO.C"
166 
167 
168 // ************************************************************************* //
Template class for intrusive linked lists.
Definition: ILList.H:50
Template class for intrusive linked lists.
Definition: UILList.H:51
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
tUEqn clear()
void transfer(ILList< LListBase, T > &)
Transfer the contents of the argument into this List.
Definition: ILList.C:130
bool erase(T *p)
Remove the specified element from the list and delete it.
Definition: ILList.C:101
An STL-conforming const_iterator.
Definition: UILList.H:234
T clone(const T &t)
Definition: List.H:54
ILList()
Null construct.
Definition: ILList.H:80
bool eraseHead()
Remove the head element specified from the list and delete it.
Definition: ILList.C:86
void clear()
Clear the contents of the list.
Definition: ILList.C:117
const iterator & end()
Definition: UILList.H:223
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
const volScalarField & T
volScalarField & p
iterator begin()
Definition: UILList.H:218
~ILList()
Destructor.
Definition: ILList.C:77
void operator=(const ILList< LListBase, T > &)
Assignment operator.
Definition: ILList.C:140