All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LPtrList.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 "LPtrList.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class LListBase, class T>
31 Foam::LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& lst)
32 {
33  for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
34  {
35  this->append(iter().clone().ptr());
36  }
37 }
38 
39 
40 template<class LListBase, class T>
41 Foam::LPtrList<LListBase, T>::LPtrList(LPtrList<LListBase, T>&& lst)
42 {
43  transfer(lst);
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
48 
49 template<class LListBase, class T>
51 {
52  this->clear();
53 }
54 
55 
56 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
57 
58 template<class LListBase, class T>
60 {
61  T* tPtr;
62  if ((tPtr = this->removeHead()))
63  {
64  delete tPtr;
65  return true;
66  }
67  else
68  {
69  return false;
70  }
71 }
72 
73 
74 template<class LListBase, class T>
76 {
77  const label oldSize = this->size();
78  for (label i=0; i<oldSize; ++i)
79  {
80  eraseHead();
81  }
82 
84 }
85 
86 
87 template<class LListBase, class T>
89 {
90  clear();
92 }
93 
94 
95 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
96 
97 template<class LListBase, class T>
99 {
100  clear();
101 
102  for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
103  {
104  this->append(iter().clone().ptr());
105  }
106 }
107 
108 
109 template<class LListBase, class T>
111 {
112  transfer(lst);
113 }
114 
115 
116 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
117 
118 #include "LPtrListIO.C"
119 
120 
121 // ************************************************************************* //
void operator=(const LPtrList< LListBase, T > &)
Assignment operator.
Definition: LPtrList.C:98
void transfer(LPtrList< LListBase, T > &)
Transfer the contents of the argument into this List.
Definition: LPtrList.C:88
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
const iterator & end()
Definition: LList.H:286
Template class for non-intrusive linked lists.
Definition: LList.H:51
bool eraseHead()
Remove the head element from the list and delete the pointer.
Definition: LPtrList.C:59
An STL-conforming const_iterator.
Definition: LPtrList.H:221
~LPtrList()
Destructor.
Definition: LPtrList.C:50
Template class for non-intrusive linked PtrLists.
Definition: LPtrList.H:47
T clone(const T &t)
Definition: List.H:54
const volScalarField & T
void clear()
Clear the contents of the list.
Definition: LPtrList.C:75
LPtrList()
Null construct.
Definition: LPtrList.H:94