LList.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 "LList.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class LListBase, class T>
32 :
33  LListBase()
34 {
35  for (const T& val : lst)
36  {
37  this->append(val);
38  }
39 }
40 
41 
42 template<class LListBase, class T>
44 :
45  LListBase()
46 {
47  transfer(lst);
48 }
49 
50 
51 template<class LListBase, class T>
52 Foam::LList<LListBase, T>::LList(std::initializer_list<T> lst)
53 :
54  LListBase()
55 {
56  for (const T& val : lst)
57  {
58  this->append(val);
59  }
60 }
61 
62 
63 template<class LListBase, class T>
65 {
66  this->clear();
67 }
68 
69 
70 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
71 
72 template<class LListBase, class T>
74 {
75  label oldSize = this->size();
76  for (label i=0; i<oldSize; ++i)
77  {
78  this->removeHead();
79  }
80 
82 }
83 
84 
85 template<class LListBase, class T>
87 {
88  clear();
89  LListBase::transfer(lst);
90 }
91 
92 
93 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
94 
95 template<class LListBase, class T>
97 {
98  this->clear();
99 
100  for (const T& val : lst)
101  {
102  this->append(val);
103  }
104 }
105 
106 
107 template<class LListBase, class T>
109 {
110  transfer(lst);
111 }
112 
113 
114 template<class LListBase, class T>
115 void Foam::LList<LListBase, T>::operator=(std::initializer_list<T> lst)
116 {
117  this->clear();
118 
119  for (const T& val : lst)
120  {
121  this->append(val);
122  }
123 }
124 
125 
126 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
127 
128 #include "LListIO.C"
129 
130 // ************************************************************************* //
Template class for non-intrusive linked lists.
Definition: LList.H:76
void operator=(const LList< LListBase, T > &)
Assignment operator.
Definition: LList.C:96
LList()
Null construct.
Definition: LList.H:108
void append(const T &a)
Add at tail of list.
Definition: LList.H:172
void clear()
Delete contents of list.
Definition: LList.C:73
void transfer(LList< LListBase, T > &)
Transfer the contents of the argument into this List.
Definition: LList.C:86
~LList()
Destructor.
Definition: LList.C:64
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
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)