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

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