/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "Swap.H" // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // template inline int Foam::Pair::compare(const Pair& a, const Pair& b) { if (a.first() == b.first() && a.second() == b.second()) { return 1; } if (a.first() == b.second() && a.second() == b.first()) { return -1; } return 0; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template inline Foam::Pair::Pair() {} template inline Foam::Pair::Pair(const T& f, const T& s) { first() = f; second() = s; } template inline Foam::Pair::Pair(const FixedList& lst) : FixedList(lst) {} template inline Foam::Pair::Pair(const T& f, const T& s, const bool doSort) { if (doSort && f < s) { first() = s; second() = f; } else { first() = f; second() = s; } } template inline Foam::Pair::Pair(const FixedList& lst, const bool doSort) : Pair(lst.first(), lst.last(), doSort) {} template inline Foam::Pair::Pair(Istream& is) : FixedList(is) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template inline const T& Foam::Pair::second() const { return last(); } template inline T& Foam::Pair::second() { return last(); } template inline const T& Foam::Pair::other(const T& a) const { if (first() == second()) { FatalErrorInFunction << "Call to other only valid for Pair with differing elements:" << *this << abort(FatalError); } else if (a == first()) { return second(); } else if (a != second()) { FatalErrorInFunction << "Pair " << *this << " does not contain " << a << abort(FatalError); } return first(); } template inline bool Foam::Pair::sorted() const { return (first() < second()); } template inline void Foam::Pair::flip() { Foam::Swap(first(), second()); } template inline void Foam::Pair::sort() { if (second() < first()) { flip(); } } // ************************************************************************* //