FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include <OpenFOAM/ILList.H>
00027 
00028 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00029 
00030 template<class LListBase, class T>
00031 Foam::ILList<LListBase, T>::ILList(const ILList<LListBase, T>& lst)
00032 :
00033     UILList<LListBase, T>()
00034 {
00035     for
00036     (
00037         typename UILList<LListBase, T>::const_iterator iter = lst.begin();
00038         iter != lst.end();
00039         ++iter
00040     )
00041     {
00042         this->append(iter().clone().ptr());
00043     }
00044 }
00045 
00046 
00047 #ifndef __INTEL_COMPILER
00048 template<class LListBase, class T>
00049 template<class CloneArg>
00050 Foam::ILList<LListBase, T>::ILList
00051 (
00052     const ILList<LListBase, T>& lst,
00053     const CloneArg& cloneArg
00054 )
00055 :
00056     UILList<LListBase, T>()
00057 {
00058     for
00059     (
00060         typename UILList<LListBase, T>::const_iterator iter = lst.begin();
00061         iter != lst.end();
00062         ++iter
00063     )
00064     {
00065         this->append(iter().clone(cloneArg).ptr());
00066     }
00067 }
00068 #endif
00069 
00070 
00071 // * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * * //
00072 
00073 template<class LListBase, class T>
00074 Foam::ILList<LListBase, T>::~ILList()
00075 {
00076     this->clear();
00077 }
00078 
00079 
00080 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00081 
00082 template<class LListBase, class T>
00083 bool Foam::ILList<LListBase, T>::eraseHead()
00084 {
00085     T* tPtr;
00086     if ((tPtr = this->removeHead()))
00087     {
00088         delete tPtr;
00089         return true;
00090     }
00091     else
00092     {
00093         return false;
00094     }
00095 }
00096 
00097 template<class LListBase, class T>
00098 bool Foam::ILList<LListBase, T>::erase(T* p)
00099 {
00100     T* tPtr;
00101     if ((tPtr = remove(p)))
00102     {
00103         delete tPtr;
00104         return true;
00105     }
00106     else
00107     {
00108         return false;
00109     }
00110 }
00111 
00112 
00113 template<class LListBase, class T>
00114 void Foam::ILList<LListBase, T>::clear()
00115 {
00116     label oldSize = this->size();
00117     for (label i=0; i<oldSize; i++)
00118     {
00119         eraseHead();
00120     }
00121 
00122     LListBase::clear();
00123 }
00124 
00125 
00126 template<class LListBase, class T>
00127 void Foam::ILList<LListBase, T>::transfer(ILList<LListBase, T>& lst)
00128 {
00129     clear();
00130     LListBase::transfer(lst);
00131 }
00132 
00133 
00134 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00135 
00136 template<class LListBase, class T>
00137 void Foam::ILList<LListBase, T>::operator=(const ILList<LListBase, T>& lst)
00138 {
00139     this->clear();
00140 
00141     for
00142     (
00143         typename UILList<LListBase, T>::const_iterator iter = lst.begin();
00144         iter != lst.end();
00145         ++iter
00146     )
00147     {
00148         this->append(iter().clone().ptr());
00149     }
00150 }
00151 
00152 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00153 
00154 #include <OpenFOAM/ILListIO.C>
00155 
00156 
00157 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines