LPtrList.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 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "LPtrList.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class LListBase, class T>
33 Foam::LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& lst)
34 :
35  LList<LListBase, T*>()
36 {
37  for (auto iter = lst.cbegin(); iter != lst.cend(); ++iter)
38  {
39  this->append((*iter).clone().ptr());
40  }
41 }
42 
43 
44 template<class LListBase, class T>
45 Foam::LPtrList<LListBase, T>::LPtrList(LPtrList<LListBase, T>&& lst)
46 :
47  LList<LListBase, T*>()
48 {
50 }
51 
52 
53 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
54 
55 template<class LListBase, class T>
57 {
58  this->clear();
59 }
60 
61 
62 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
63 
64 template<class LListBase, class T>
66 {
67  T* p = this->removeHead();
68 
69  if (p)
70  {
71  delete p;
72  return true;
73  }
74 
75  return false;
76 }
77 
78 
79 template<class LListBase, class T>
81 {
82  const label len = this->size();
83  for (label i=0; i<len; ++i)
84  {
85  eraseHead();
86  }
87 
89 }
90 
91 
92 template<class LListBase, class T>
94 {
95  clear();
97 }
98 
99 
100 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
101 
102 template<class LListBase, class T>
104 {
105  clear();
106 
107  for (auto iter = lst.cbegin(); iter != lst.cend(); ++iter)
108  {
109  this->append((*iter).clone().ptr());
110  }
111 }
112 
113 
114 template<class LListBase, class T>
116 {
117  transfer(lst);
118 }
119 
120 
121 // ************************************************************************* //
Foam::LPtrList::cbegin
const_iterator cbegin() const
Iterator to first item in list with const access.
Definition: LPtrList.H:352
p
volScalarField & p
Definition: createFieldRefs.H:8
append
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
Foam::LList::clear
void clear()
Delete contents of list.
Definition: LList.C:77
Foam::LPtrList
Template class for non-intrusive linked PtrLists.
Definition: LPtrList.H:50
Foam::LList
Template class for non-intrusive linked lists.
Definition: LList.H:54
Foam::LPtrList::transfer
void transfer(LPtrList< LListBase, T > &lst)
Definition: LPtrList.C:93
Foam::LPtrList::operator=
void operator=(const LPtrList< LListBase, T > &lst)
Copy assign by using 'clone()' for each element.
Definition: LPtrList.C:103
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
LPtrList.H
Foam::LPtrList::~LPtrList
~LPtrList()
Destructor.
Definition: LPtrList.C:56
T
const volScalarField & T
Definition: createFieldRefs.H:2
Foam::LPtrList::eraseHead
bool eraseHead()
Remove the head element from the list and delete the pointer.
Definition: LPtrList.C:65
clear
patchWriters clear()
Foam::LPtrList::cend
const const_iterator & cend() const
End of list for forward iterators.
Definition: LPtrList.H:389
Foam::LPtrList::LPtrList
LPtrList()=default
Null construct.
Foam::LList::transfer
void transfer(LList< LListBase, T > &lst)
Transfer the contents of the argument into this List.
Definition: LList.C:90
Foam::LPtrList::clear
void clear()
Clear the contents of the list.
Definition: LPtrList.C:80