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-2020 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  UILList<LListBase, T>()
34 {
35  for
36  (
37  typename UILList<LListBase, T>::const_iterator iter = lst.begin();
38  iter != lst.end();
39  ++iter
40  )
41  {
42  this->append(iter().clone().ptr());
43  }
44 }
45 
46 
47 template<class LListBase, class T>
49 :
50  UILList<LListBase, T>()
51 {
52  transfer(lst);
53 }
54 
55 
56 template<class LListBase, class T>
57 template<class CloneArg>
59 (
60  const ILList<LListBase, T>& lst,
61  const CloneArg& cloneArg
62 )
63 :
65 {
66  for
67  (
68  typename UILList<LListBase, T>::const_iterator iter = lst.begin();
69  iter != lst.end();
70  ++iter
71  )
72  {
73  this->append(iter().clone(cloneArg).ptr());
74  }
75 }
76 
77 
78 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
79 
80 template<class LListBase, class T>
82 {
83  this->clear();
84 }
85 
86 
87 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
88 
89 template<class LListBase, class T>
91 {
92  T* tPtr;
93  if ((tPtr = this->removeHead()))
94  {
95  delete tPtr;
96  return true;
97  }
98  else
99  {
100  return false;
101  }
102 }
103 
104 template<class LListBase, class T>
106 {
107  T* tPtr;
108  if ((tPtr = remove(p)))
109  {
110  delete tPtr;
111  return true;
112  }
113  else
114  {
115  return false;
116  }
117 }
118 
119 
120 template<class LListBase, class T>
122 {
123  label oldSize = this->size();
124  for (label i=0; i<oldSize; ++i)
125  {
126  eraseHead();
127  }
128 
130 }
131 
132 
133 template<class LListBase, class T>
135 {
136  clear();
137  LListBase::transfer(lst);
138 }
139 
140 
141 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
142 
143 template<class LListBase, class T>
145 {
146  this->clear();
147 
148  for
149  (
150  typename UILList<LListBase, T>::const_iterator iter = lst.begin();
151  iter != lst.end();
152  ++iter
153  )
154  {
155  this->append(iter().clone().ptr());
156  }
157 }
158 
159 
160 template<class LListBase, class T>
162 {
163  transfer(lst);
164 }
165 
166 
167 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
168 
169 #include "ILListIO.C"
170 
171 
172 // ************************************************************************* //
Template class for intrusive linked lists.
Definition: ILList.H:50
Template class for intrusive linked lists.
Definition: UILList.H:51
tUEqn clear()
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
void transfer(ILList< LListBase, T > &)
Transfer the contents of the argument into this List.
Definition: ILList.C:134
bool erase(T *p)
Remove the specified element from the list and delete it.
Definition: ILList.C:105
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:90
void clear()
Clear the contents of the list.
Definition: ILList.C:121
const iterator & end()
Definition: UILList.H:223
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const volScalarField & T
volScalarField & p
T * removeHead()
Remove and return head.
Definition: UILList.H:136
iterator begin()
Definition: UILList.H:218
~ILList()
Destructor.
Definition: ILList.C:81
void operator=(const ILList< LListBase, T > &)
Assignment operator.
Definition: ILList.C:144