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 | Copyright (C) 2011-2015 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>
48 template<class CloneArg>
50 (
51  const ILList<LListBase, T>& lst,
52  const CloneArg& cloneArg
53 )
54 :
56 {
57  for
58  (
59  typename UILList<LListBase, T>::const_iterator iter = lst.begin();
60  iter != lst.end();
61  ++iter
62  )
63  {
64  this->append(iter().clone(cloneArg).ptr());
65  }
66 }
67 
68 
69 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
70 
71 template<class LListBase, class T>
73 {
74  this->clear();
75 }
76 
77 
78 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
79 
80 template<class LListBase, class T>
82 {
83  T* tPtr;
84  if ((tPtr = this->removeHead()))
85  {
86  delete tPtr;
87  return true;
88  }
89  else
90  {
91  return false;
92  }
93 }
94 
95 template<class LListBase, class T>
97 {
98  T* tPtr;
99  if ((tPtr = remove(p)))
100  {
101  delete tPtr;
102  return true;
103  }
104  else
105  {
106  return false;
107  }
108 }
109 
110 
111 template<class LListBase, class T>
113 {
114  label oldSize = this->size();
115  for (label i=0; i<oldSize; ++i)
116  {
117  eraseHead();
118  }
119 
121 }
122 
123 
124 template<class LListBase, class T>
126 {
127  clear();
128  LListBase::transfer(lst);
129 }
130 
131 
132 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
133 
134 template<class LListBase, class T>
136 {
137  this->clear();
138 
139  for
140  (
141  typename UILList<LListBase, T>::const_iterator iter = lst.begin();
142  iter != lst.end();
143  ++iter
144  )
145  {
146  this->append(iter().clone().ptr());
147  }
148 }
149 
150 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
151 
152 #include "ILListIO.C"
153 
154 
155 // ************************************************************************* //
T * removeHead()
Remove and return head.
Definition: UILList.H:133
ILList()
Null construct.
Definition: ILList.H:80
void clear()
Clear the contents of the list.
Definition: ILList.C:112
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Template class for intrusive linked lists.
Definition: ILList.H:50
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
iterator begin()
Definition: UILList.H:211
~ILList()
Destructor.
Definition: ILList.C:72
bool eraseHead()
Remove the head element specified from the list and delete it.
Definition: ILList.C:81
const volScalarField & T
Definition: createFields.H:25
void transfer(ILList< LListBase, T > &)
Transfer the contents of the argument into this List.
Definition: ILList.C:125
void operator=(const ILList< LListBase, T > &)
Definition: ILList.C:135
volScalarField & p
Definition: createFields.H:51
bool erase(T *p)
Remove the specified element from the list and delete it.
Definition: ILList.C:96
Template class for intrusive linked lists.
Definition: UILList.H:51
An STL-conforming const_iterator.
Definition: UILList.H:227
const iterator & end()
Definition: UILList.H:216
UEqn clear()