FreeFOAM The Cross-Platform CFD Toolkit
FixedList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "FixedList.H"
27 #include <OpenFOAM/ListLoopM.H>
28 
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 
31 // * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * //
32 
33 template<class T, unsigned Size>
35 {
36  List_ACCESS(T, (*this), vp);
37  List_ACCESS(T, a, ap);
38  T tmp;
39  List_FOR_ALL((*this), i)
40  tmp = List_ELEM((*this), vp, i);
41  List_ELEM((*this), vp, i) = List_ELEM(a, ap, i);
42  List_ELEM(a, ap, i) = tmp;
44 }
45 
46 
47 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
48 
49 template<class T, unsigned Size>
51 {
52  bool equal = true;
53 
54  List_CONST_ACCESS(T, (*this), vp);
55  List_CONST_ACCESS(T, (a), ap);
56 
57  List_FOR_ALL((*this), i)
58  equal = equal && (List_ELEM((*this), vp, i) == List_ELEM((a), ap, i));
60 
61  return equal;
62 }
63 
64 
65 template<class T, unsigned Size>
67 {
68  return !operator==(a);
69 }
70 
71 
72 template<class T, unsigned Size>
74 {
75  for
76  (
77  const_iterator vi = cbegin(), ai = a.cbegin();
78  vi < cend() && ai < a.cend();
79  vi++, ai++
80  )
81  {
82  if (*vi < *ai)
83  {
84  return true;
85  }
86  else if (*vi > *ai)
87  {
88  return false;
89  }
90  }
91 
92  if (Size < a.Size)
93  {
94  return true;
95  }
96  else
97  {
98  return false;
99  }
100 }
101 
102 
103 template<class T, unsigned Size>
105 {
106  return a.operator<(*this);
107 }
108 
109 
110 template<class T, unsigned Size>
112 {
113  return !operator>(a);
114 }
115 
116 
117 template<class T, unsigned Size>
119 {
120  return !operator<(a);
121 }
122 
123 
124 // * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
125 
126 #include "FixedListIO.C"
127 
128 // ************************ vim: set sw=4 sts=4 et: ************************ //