mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Pair: Add extra comparison operators. Make member functions non-member
This commit is contained in:
@ -108,12 +108,6 @@ public:
|
|||||||
return this->operator[](1);
|
return this->operator[](1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return reverse pair
|
|
||||||
inline Pair<Type> reversePair() const
|
|
||||||
{
|
|
||||||
return Pair<Type>(second(), first());
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return other
|
//- Return other
|
||||||
inline const Type& other(const Type& a) const
|
inline const Type& other(const Type& a) const
|
||||||
{
|
{
|
||||||
@ -147,11 +141,11 @@ public:
|
|||||||
// - -1: same pair, but reversed order
|
// - -1: same pair, but reversed order
|
||||||
static inline int compare(const Pair<Type>& a, const Pair<Type>& b)
|
static inline int compare(const Pair<Type>& a, const Pair<Type>& b)
|
||||||
{
|
{
|
||||||
if (a[0] == b[0] && a[1] == b[1])
|
if (a == b)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (a[0] == b[1] && a[1] == b[0])
|
else if (a == reverse(b))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -160,21 +154,32 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Friend Operators
|
template<class Type>
|
||||||
|
Pair<Type> reverse(const Pair<Type>& p)
|
||||||
|
{
|
||||||
|
return Pair<Type>(p.second(), p.first());
|
||||||
|
}
|
||||||
|
|
||||||
friend bool operator==(const Pair<Type>& a, const Pair<Type>& b)
|
|
||||||
|
template<class Type>
|
||||||
|
bool operator==(const Pair<Type>& a, const Pair<Type>& b)
|
||||||
{
|
{
|
||||||
return (a.first() == b.first() && a.second() == b.second());
|
return (a.first() == b.first() && a.second() == b.second());
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator!=(const Pair<Type>& a, const Pair<Type>& b)
|
|
||||||
|
template<class Type>
|
||||||
|
bool operator!=(const Pair<Type>& a, const Pair<Type>& b)
|
||||||
{
|
{
|
||||||
return !(a == b);
|
return !(a == b);
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator<(const Pair<Type>& a, const Pair<Type>& b)
|
|
||||||
|
template<class Type>
|
||||||
|
bool operator<(const Pair<Type>& a, const Pair<Type>& b)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
@ -186,7 +191,27 @@ public:
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
bool operator<=(const Pair<Type>& a, const Pair<Type>& b)
|
||||||
|
{
|
||||||
|
return !(b < a);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
bool operator>(const Pair<Type>& a, const Pair<Type>& b)
|
||||||
|
{
|
||||||
|
return (b < a);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
bool operator>=(const Pair<Type>& a, const Pair<Type>& b)
|
||||||
|
{
|
||||||
|
return !(a < b);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -450,7 +450,7 @@ Foam::Map<Foam::labelPair> Foam::meshRefinement::getZoneBafflePatches
|
|||||||
labelPair patches = zPatches;
|
labelPair patches = zPatches;
|
||||||
if (fZone.flipMap()[i])
|
if (fZone.flipMap()[i])
|
||||||
{
|
{
|
||||||
patches = patches.reversePair();
|
patches = reverse(patches);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bafflePatch.insert(faceI, patches))
|
if (!bafflePatch.insert(faceI, patches))
|
||||||
|
|||||||
Reference in New Issue
Block a user