initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / containers / LinkedLists / accessTypes / ILList / ILList.C
blob670a3116a4221db6204764f42870bff1078c9f29
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "ILList.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 template<class LListBase, class T>
37 ILList<LListBase, T>::ILList(const ILList<LListBase, T>& slpl)
39     UILList<LListBase, T>()
41     for
42     (
43         typename UILList<LListBase, T>::const_iterator iter = slpl.begin();
44         iter != slpl.end();
45         ++iter
46     )
47     {
48         append(iter().clone().ptr());
49     }
53 #ifndef __INTEL_COMPILER
54 template<class LListBase, class T>
55 template<class CloneArg>
56 ILList<LListBase, T>::ILList
58     const ILList<LListBase, T>& slpl,
59     const CloneArg& cloneArg
62     UILList<LListBase, T>()
64     for
65     (
66         typename UILList<LListBase, T>::const_iterator iter = slpl.begin();
67         iter != slpl.end();
68         ++iter
69     )
70     {
71         append(iter().clone(cloneArg).ptr());
72     }
74 #endif
77 // * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * * //
79 template<class LListBase, class T>
80 ILList<LListBase, T>::~ILList()
82     this->clear();
86 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
88 //- Return and remove head
89 template<class LListBase, class T>
90 bool ILList<LListBase, T>::eraseHead()
92     T* tPtr;
93     if ((tPtr = this->removeHead()))
94     {
95         delete tPtr;
96         return true;
97     }
98     else
99     {
100         return false;
101     }
104 //- Return and remove element
105 template<class LListBase, class T>
106 bool ILList<LListBase, T>::erase(T* p)
108     T* tPtr;
109     if ((tPtr = remove(p)))
110     {
111         delete tPtr;
112         return true;
113     }
114     else
115     {
116         return false;
117     }
121 template<class LListBase, class T>
122 void ILList<LListBase, T>::clear()
124     label oldSize = this->size();
125     for (label i=0; i<oldSize; i++)
126     {
127         eraseHead();
128     }
130     LListBase::clear();
134 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
136 template<class LListBase, class T>
137 void ILList<LListBase, T>::operator=(const ILList<LListBase, T>& slpl)
139     this->clear();
141     for
142     (
143         typename UILList<LListBase, T>::const_iterator iter = slpl.begin();
144         iter != slpl.end();
145         ++iter
146     )
147     {
148         append(iter().clone().ptr());
149     }
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 } // End namespace Foam
157 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
159 #include "ILListIO.C"
162 // ************************************************************************* //