Loading...
Searching...
No Matches
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 Copyright (C) 2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "LPtrList.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33template<class LListBase, class T>
34Foam::LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& lst)
35:
36 LList<LListBase, T*>()
37{
38 for (auto iter = lst.cbegin(); iter != lst.cend(); ++iter)
39 {
40 this->push_back((*iter).clone().ptr());
41 }
42}
43
44
45template<class LListBase, class T>
47:
48 LList<LListBase, T*>()
49{
54// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
55
56template<class LListBase, class T>
58{
59 this->clear();
60}
61
62
63// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64
65template<class LListBase, class T>
67{
68 if (n > this->size())
69 {
70 n = this->size();
71 }
72
73 while (n > 0)
74 {
75 T* p = this->removeHead();
76 delete p;
77 --n;
78 }
79}
80
81
82template<class LListBase, class T>
85 this->pop_front(this->size());
87}
88
89
90template<class LListBase, class T>
92{
93 clear();
95}
96
97
98// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
99
100template<class LListBase, class T>
102{
103 clear();
104
105 for (auto iter = lst.cbegin(); iter != lst.cend(); ++iter)
107 this->push_back((*iter).clone().ptr());
108 }
109}
110
111
112template<class LListBase, class T>
113void Foam::LPtrList<LListBase, T>::operator=(LPtrList<LListBase, T>&& lst)
114{
115 transfer(lst);
116}
117
118
119// ************************************************************************* //
label n
Template class for non-intrusive linked lists.
Definition LList.H:71
void transfer(LList< LListBase, T > &lst)
Transfer the contents of the argument into this List and annul the argument list.
Definition LList.C:96
void push_back(const T &elem)
Definition LList.H:299
void clear()
Delete contents of list.
Definition LList.C:88
Template class for non-intrusive linked PtrLists.
Definition LPtrList.H:71
void pop_front(label n=1)
Remove first element(s) from the list (deletes pointers).
Definition LPtrList.C:59
const_iterator cbegin() const
Iterator to first item in list with const access.
Definition LPtrList.H:431
const const_iterator & cend() const
End of list for forward iterators.
Definition LPtrList.H:480
void operator=(const LPtrList< LListBase, T > &lst)
Copy assign by using 'clone()' for each element.
Definition LPtrList.C:94
void transfer(LPtrList< LListBase, T > &lst)
Transfer the contents of the argument into this List and annul the argument list.
Definition LPtrList.C:84
void clear()
Clear the contents of the list.
Definition LPtrList.C:76
LPtrList()=default
Default construct.
~LPtrList()
Destructor. Calls clear().
Definition LPtrList.C:50
volScalarField & p
const volScalarField & T
surface1 clear()
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)