FreeFOAM The Cross-Platform CFD Toolkit
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 | 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/ILList.H>
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class LListBase, class T>
32 :
33  UILList<LListBase, T>()
34 {
35  for
36  (
37  typename UILList<LListBase, T>::const_iterator iter = lst.begin();
38  iter != lst.end();
39  ++iter
40  )
41  {
42  append(iter().clone().ptr());
43  }
44 }
45 
46 
47 #ifndef __INTEL_COMPILER
48 template<class LListBase, class T>
49 template<class CloneArg>
51 (
52  const ILList<LListBase, T>& lst,
53  const CloneArg& cloneArg
54 )
55 :
57 {
58  for
59  (
60  typename UILList<LListBase, T>::const_iterator iter = lst.begin();
61  iter != lst.end();
62  ++iter
63  )
64  {
65  append(iter().clone(cloneArg).ptr());
66  }
67 }
68 #endif
69 
70 
71 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
72 
73 template<class LListBase, class T>
75 {
76  this->clear();
77 }
78 
79 
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 
82 template<class LListBase, class T>
84 {
85  T* tPtr;
86  if ((tPtr = this->removeHead()))
87  {
88  delete tPtr;
89  return true;
90  }
91  else
92  {
93  return false;
94  }
95 }
96 
97 template<class LListBase, class T>
99 {
100  T* tPtr;
101  if ((tPtr = remove(p)))
102  {
103  delete tPtr;
104  return true;
105  }
106  else
107  {
108  return false;
109  }
110 }
111 
112 
113 template<class LListBase, class T>
115 {
116  label oldSize = this->size();
117  for (label i=0; i<oldSize; i++)
118  {
119  eraseHead();
120  }
121 
123 }
124 
125 
126 template<class LListBase, class T>
128 {
129  clear();
130  LListBase::transfer(lst);
131 }
132 
133 
134 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
135 
136 template<class LListBase, class T>
138 {
139  this->clear();
140 
141  for
142  (
143  typename UILList<LListBase, T>::const_iterator iter = lst.begin();
144  iter != lst.end();
145  ++iter
146  )
147  {
148  append(iter().clone().ptr());
149  }
150 }
151 
152 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
153 
154 #include <OpenFOAM/ILListIO.C>
155 
156 
157 // ************************ vim: set sw=4 sts=4 et: ************************ //