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-2022 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  return false;
91 }
92 
93 
94 template<class T, unsigned Size>
96 {
97  return a.operator<(*this);
98 }
99 
100 
101 template<class T, unsigned Size>
103 {
104  return !operator>(a);
105 }
106 
107 
108 template<class T, unsigned Size>
110 {
111  return !operator<(a);
112 }
113 
114 
115 // * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
116 
117 #include "FixedListIO.C"
118 
119 // ************************************************************************* //
List<T> is a 1D vector of objects of type T, where the size of the vector is known and used for subsc...
#define List_CELEM(f, fp, i)
Definition: ListLoopM.H:70
#define List_END_FOR_ALL
Definition: ListLoopM.H:67
#define List_ACCESS(type, f, fp)
Definition: ListLoopM.H:75
#define List_ELEM(f, fp, i)
Definition: ListLoopM.H:73
#define List_FOR_ALL(f, i)
Definition: ListLoopM.H:62
#define List_CONST_ACCESS(type, f, fp)
Definition: ListLoopM.H:78
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:78
bool operator>(const FixedList< T, Size > &) const
Compare two FixedLists lexicographically. Takes linear time.
Definition: FixedList.C:95
bool operator!=(const FixedList< T, Size > &) const
The opposite of the equality operation. Takes linear time.
Definition: FixedList.C:64
const T * const_iterator
Random access iterator for traversing FixedList.
Definition: FixedList.H:270
const_iterator cend() const
Return const_iterator to end traversing the constant FixedList.
Definition: FixedListI.H:347
bool operator>=(const FixedList< T, Size > &) const
Return true if !(a < b). Takes linear time.
Definition: FixedList.C:109
friend Ostream & operator(Ostream &, const FixedList< T, Size > &)
Write FixedList to Ostream.
bool operator==(const FixedList< T, Size > &) const
Equality operation on FixedLists of the same type.
Definition: FixedList.C:48
const_iterator cbegin() const
Return const_iterator to begin traversing the constant FixedList.
Definition: FixedListI.H:339
bool operator<=(const FixedList< T, Size > &) const
Return true if !(a > b). Takes linear time.
Definition: FixedList.C:102
bool operator<(const FixedList< T, Size > &) const
Compare two FixedLists lexicographically. Takes linear time.
Definition: FixedList.C:71
void swap(FixedList< T, Size > &)
Swap two FixedLists of the same type in constant time.
Definition: FixedList.C:32
A class for managing temporary objects.
Definition: tmp.H:55
bool equal(const T &s1, const T &s2)
Definition: doubleFloat.H:62
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
bool operator<(const instant &, const instant &)
Definition: instant.C:79
bool operator>(const instant &, const instant &)
Definition: instant.C:85
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)