FreeFOAM The Cross-Platform CFD Toolkit
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 | Copyright (C) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/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  LList<LListBase, T*>()
34 {
35  for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
36  {
37  append(iter().clone().ptr());
38  }
39 }
40 
41 
42 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
43 
44 template<class LListBase, class T>
46 {
47  clear();
48 }
49 
50 
51 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
52 
53 template<class LListBase, class T>
55 {
56  T* tPtr;
57  if ((tPtr = this->removeHead()))
58  {
59  delete tPtr;
60  return true;
61  }
62  else
63  {
64  return false;
65  }
66 }
67 
68 
69 template<class LListBase, class T>
71 {
72  label oldSize = this->size();
73  for (label i=0; i<oldSize; i++)
74  {
75  eraseHead();
76  }
77 
79 }
80 
81 
82 template<class LListBase, class T>
84 {
85  clear();
87 }
88 
89 
90 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
91 
92 template<class LListBase, class T>
94 {
95  clear();
96 
97  for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
98  {
99  append(iter().clone().ptr());
100  }
101 }
102 
103 
104 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
105 
106 #include <OpenFOAM/LPtrListIO.C>
107 
108 
109 // ************************ vim: set sw=4 sts=4 et: ************************ //