FixedList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
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 "ListLoopM.H"
28 
29 // * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * //
30 
31 template<class T, unsigned Size>
33 {
34  List_ACCESS(T, (*this), vp);
35  List_ACCESS(T, a, ap);
36  T tmp;
37  List_FOR_ALL((*this), i)
38  tmp = List_CELEM((*this), vp, i);
39  List_ELEM((*this), vp, i) = List_CELEM(a, ap, i);
40  List_ELEM(a, ap, i) = tmp;
42 }
43 
44 
45 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
46 
47 template<class T, unsigned Size>
49 {
50  bool equal = true;
51 
52  List_CONST_ACCESS(T, (*this), vp);
53  List_CONST_ACCESS(T, (a), ap);
54 
55  List_FOR_ALL((*this), i)
56  equal = equal && (List_ELEM((*this), vp, i) == List_ELEM((a), ap, i));
58 
59  return equal;
60 }
61 
62 
63 template<class T, unsigned Size>
65 {
66  return !operator==(a);
67 }
68 
69 
70 template<class T, unsigned Size>
72 {
73  for
74  (
75  const_iterator vi = cbegin(), ai = a.cbegin();
76  vi < cend() && ai < a.cend();
77  vi++, ai++
78  )
79  {
80  if (*vi < *ai)
81  {
82  return true;
83  }
84  else if (*vi > *ai)
85  {
86  return false;
87  }
88  }
89 
90  if (Size < a.Size)
91  {
92  return true;
93  }
94  else
95  {
96  return false;
97  }
98 }
99 
100 
101 template<class T, unsigned Size>
103 {
104  return a.operator<(*this);
105 }
106 
107 
108 template<class T, unsigned Size>
110 {
111  return !operator>(a);
112 }
113 
114 
115 template<class T, unsigned Size>
117 {
118  return !operator<(a);
119 }
120 
121 
122 // * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
123 
124 #include "FixedListIO.C"
125 
126 // ************************************************************************* //
#define List_CELEM(f, fp, i)
Definition: ListLoopM.H:70
#define List_CONST_ACCESS(type, f, fp)
Definition: ListLoopM.H:78
const_iterator cend() const
Return const_iterator to end traversing the constant FixedList.
Definition: FixedListI.H:364
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:54
bool operator<(const instant &, const instant &)
Definition: instant.C:79
bool operator>=(const FixedList< T, Size > &) const
Return true if !(a < b). Takes linear time.
Definition: FixedList.C:116
friend Ostream & operator(Ostream &, const FixedList< T, Size > &)
Write FixedList to Ostream.
bool operator<=(const FixedList< T, Size > &) const
Return true if !(a > b). Takes linear time.
Definition: FixedList.C:109
bool operator!=(const FixedList< T, Size > &) const
The opposite of the equality operation. Takes linear time.
Definition: FixedList.C:64
#define List_END_FOR_ALL
Definition: ListLoopM.H:67
const Type * const_iterator
Random access iterator for traversing FixedList.
Definition: FixedList.H:270
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
bool operator==(const FixedList< T, Size > &) const
Equality operation on FixedLists of the same type.
Definition: FixedList.C:48
void swap(FixedList< T, Size > &)
Swap two FixedLists of the same type in constant time.
Definition: FixedList.C:32
bool operator>(const instant &, const instant &)
Definition: instant.C:85
List<T> is a 1D vector of objects of type T, where the size of the vector is known and used for subsc...
bool operator>(const FixedList< T, Size > &) const
Compare two FixedLists lexicographically. Takes linear time.
Definition: FixedList.C:102
const_iterator cbegin() const
Return const_iterator to begin traversing the constant FixedList.
Definition: FixedListI.H:340
#define List_ELEM(f, fp, i)
Definition: ListLoopM.H:73
#define List_ACCESS(type, f, fp)
Definition: ListLoopM.H:75
const volScalarField & T
#define List_FOR_ALL(f, i)
Definition: ListLoopM.H:62
bool equal(const T &s1, const T &s2)
Definition: doubleFloat.H:62
bool operator<(const FixedList< T, Size > &) const
Compare two FixedLists lexicographically. Takes linear time.
Definition: FixedList.C:71
A class for managing temporary objects.
Definition: PtrList.H:53