OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

ILList.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "ILList.H"
00028 
00029 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00030 
00031 template<class LListBase, class T>
00032 Foam::ILList<LListBase, T>::ILList(const ILList<LListBase, T>& lst)
00033 :
00034     UILList<LListBase, T>()
00035 {
00036     for
00037     (
00038         typename UILList<LListBase, T>::const_iterator iter = lst.begin();
00039         iter != lst.end();
00040         ++iter
00041     )
00042     {
00043         append(iter().clone().ptr());
00044     }
00045 }
00046 
00047 
00048 #ifndef __INTEL_COMPILER
00049 template<class LListBase, class T>
00050 template<class CloneArg>
00051 Foam::ILList<LListBase, T>::ILList
00052 (
00053     const ILList<LListBase, T>& lst,
00054     const CloneArg& cloneArg
00055 )
00056 :
00057     UILList<LListBase, T>()
00058 {
00059     for
00060     (
00061         typename UILList<LListBase, T>::const_iterator iter = lst.begin();
00062         iter != lst.end();
00063         ++iter
00064     )
00065     {
00066         append(iter().clone(cloneArg).ptr());
00067     }
00068 }
00069 #endif
00070 
00071 
00072 // * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * * //
00073 
00074 template<class LListBase, class T>
00075 Foam::ILList<LListBase, T>::~ILList()
00076 {
00077     this->clear();
00078 }
00079 
00080 
00081 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00082 
00083 template<class LListBase, class T>
00084 bool Foam::ILList<LListBase, T>::eraseHead()
00085 {
00086     T* tPtr;
00087     if ((tPtr = this->removeHead()))
00088     {
00089         delete tPtr;
00090         return true;
00091     }
00092     else
00093     {
00094         return false;
00095     }
00096 }
00097 
00098 template<class LListBase, class T>
00099 bool Foam::ILList<LListBase, T>::erase(T* p)
00100 {
00101     T* tPtr;
00102     if ((tPtr = remove(p)))
00103     {
00104         delete tPtr;
00105         return true;
00106     }
00107     else
00108     {
00109         return false;
00110     }
00111 }
00112 
00113 
00114 template<class LListBase, class T>
00115 void Foam::ILList<LListBase, T>::clear()
00116 {
00117     label oldSize = this->size();
00118     for (label i=0; i<oldSize; i++)
00119     {
00120         eraseHead();
00121     }
00122 
00123     LListBase::clear();
00124 }
00125 
00126 
00127 template<class LListBase, class T>
00128 void Foam::ILList<LListBase, T>::transfer(ILList<LListBase, T>& lst)
00129 {
00130     clear();
00131     LListBase::transfer(lst);
00132 }
00133 
00134 
00135 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00136 
00137 template<class LListBase, class T>
00138 void Foam::ILList<LListBase, T>::operator=(const ILList<LListBase, T>& lst)
00139 {
00140     this->clear();
00141 
00142     for
00143     (
00144         typename UILList<LListBase, T>::const_iterator iter = lst.begin();
00145         iter != lst.end();
00146         ++iter
00147     )
00148     {
00149         append(iter().clone().ptr());
00150     }
00151 }
00152 
00153 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00154 
00155 #include "ILListIO.C"
00156 
00157 
00158 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd