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

FixedList.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 "FixedList.H"
00027 #include <OpenFOAM/ListLoopM.H>
00028 
00029 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00030 
00031 // * * * * * * * * * * * * * * STL Member Functions  * * * * * * * * * * * * //
00032 
00033 template<class T, unsigned Size>
00034 void Foam::FixedList<T, Size>::swap(FixedList<T, Size>& a)
00035 {
00036     List_ACCESS(T, (*this), vp);
00037     List_ACCESS(T, a, ap);
00038     T tmp;
00039     List_FOR_ALL((*this), i)
00040         tmp = List_ELEM((*this), vp, i);
00041         List_ELEM((*this), vp, i) = List_ELEM(a, ap, i);
00042         List_ELEM(a, ap, i) = tmp;
00043     List_END_FOR_ALL
00044 }
00045 
00046 
00047 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00048 
00049 template<class T, unsigned Size>
00050 bool Foam::FixedList<T, Size>::operator==(const FixedList<T, Size>& a) const
00051 {
00052     bool equal = true;
00053 
00054     List_CONST_ACCESS(T, (*this), vp);
00055     List_CONST_ACCESS(T, (a), ap);
00056 
00057     List_FOR_ALL((*this), i)
00058         equal = equal && (List_ELEM((*this), vp, i) == List_ELEM((a), ap, i));
00059     List_END_FOR_ALL
00060 
00061     return equal;
00062 }
00063 
00064 
00065 template<class T, unsigned Size>
00066 bool Foam::FixedList<T, Size>::operator!=(const FixedList<T, Size>& a) const
00067 {
00068     return !operator==(a);
00069 }
00070 
00071 
00072 template<class T, unsigned Size>
00073 bool Foam::FixedList<T, Size>::operator<(const FixedList<T, Size>& a) const
00074 {
00075     for
00076     (
00077         const_iterator vi = cbegin(), ai = a.cbegin();
00078         vi < cend() && ai < a.cend();
00079         vi++, ai++
00080     )
00081     {
00082         if (*vi < *ai)
00083         {
00084             return true;
00085         }
00086         else if (*vi > *ai)
00087         {
00088             return false;
00089         }
00090     }
00091 
00092     if (Size < a.Size)
00093     {
00094         return true;
00095     }
00096     else
00097     {
00098         return false;
00099     }
00100 }
00101 
00102 
00103 template<class T, unsigned Size>
00104 bool Foam::FixedList<T, Size>::operator>(const FixedList<T, Size>& a) const
00105 {
00106     return a.operator<(*this);
00107 }
00108 
00109 
00110 template<class T, unsigned Size>
00111 bool Foam::FixedList<T, Size>::operator<=(const FixedList<T, Size>& a) const
00112 {
00113     return !operator>(a);
00114 }
00115 
00116 
00117 template<class T, unsigned Size>
00118 bool Foam::FixedList<T, Size>::operator>=(const FixedList<T, Size>& a) const
00119 {
00120     return !operator<(a);
00121 }
00122 
00123 
00124 // * * * * * * * * * * * * * * * *  IOStream operators * * * * * * * * * * * //
00125 
00126 #include "FixedListIO.C"
00127 
00128 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines