Loading...
Searching...
No Matches
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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2015 OpenFOAM Foundation
9 Copyright (C) 2017-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 "ILList.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33template<class LListBase, class T>
35:
36 UILList<LListBase, T>()
37{
38 for (const auto& item : lst)
39 {
40 this->push_back(item.clone().ptr());
41 }
42}
43
44
45template<class LListBase, class T>
46Foam::ILList<LListBase, T>::ILList(ILList<LListBase, T>&& lst)
47:
48 UILList<LListBase, T>()
50 LListBase::transfer(lst);
51}
52
53
54template<class LListBase, class T>
55template<class CloneArg>
57(
58 const ILList<LListBase, T>& lst,
59 const CloneArg& cloneArg
60)
61:
62 UILList<LListBase, T>()
63{
64 for (const auto& item : lst)
65 {
66 this->push_back(item.clone(cloneArg).ptr());
67 }
68}
69
70
71// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
72
73template<class LListBase, class T>
75{
76 this->clear();
77}
78
79
80// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81
82template<class LListBase, class T>
84{
85 if (n > this->size())
86 {
87 n = this->size();
88 }
89
90 while (n > 0)
91 {
92 T* p = this->removeHead();
93 delete p;
94 --n;
95 }
96}
97
98
99template<class LListBase, class T>
102 this->pop_front(this->size());
103 LListBase::clear();
104}
105
106
107template<class LListBase, class T>
109{
110 T* p = remove(item);
111 delete p;
112 return bool(p);
113}
114
115
116template<class LListBase, class T>
118{
119 clear();
120 LListBase::transfer(lst);
121}
122
123
124// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
125
126template<class LListBase, class T>
128{
129 this->clear();
130
131 for (const auto& item : lst)
133 this->push_back(item.clone().ptr());
134 }
135}
136
137
138template<class LListBase, class T>
139void Foam::ILList<LListBase, T>::operator=(ILList<LListBase, T>&& lst)
140{
141 clear();
142 LListBase::transfer(lst);
143}
144
145
146// ************************************************************************* //
label n
Template class for intrusive linked lists.
Definition ILList.H:62
void pop_front(label n=1)
Remove first element(s) from the list (deletes pointers).
Definition ILList.C:76
void transfer(ILList< LListBase, T > &lst)
Transfer the contents of the argument into this List and annul the argument list.
Definition ILList.C:110
ILList()=default
Default construct.
bool erase(T *item)
Remove the specified element from the list and delete it.
Definition ILList.C:101
void clear()
Clear the contents of the list.
Definition ILList.C:93
~ILList()
Destructor. Calls clear().
Definition ILList.C:67
void operator=(const ILList< LListBase, T > &lst)
Copy assignment using the 'clone()' method for each element.
Definition ILList.C:120
Template class for intrusive linked lists.
Definition UILList.H:65
UILList()=default
Default construct.
T * remove(T *item)
Remove and return element.
Definition UILList.H:182
T * removeHead()
Remove and return head.
Definition UILList.H:174
volScalarField & p
const volScalarField & T
surface1 clear()
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)