diff options
Diffstat (limited to 'extern/mantaflow/preprocessed/general.h')
-rw-r--r-- | extern/mantaflow/preprocessed/general.h | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/extern/mantaflow/preprocessed/general.h b/extern/mantaflow/preprocessed/general.h index 7a840517cef..50eac71e87e 100644 --- a/extern/mantaflow/preprocessed/general.h +++ b/extern/mantaflow/preprocessed/general.h @@ -42,7 +42,7 @@ inline void updateQtGui(bool full, int frame, float time, const std::string &cur # ifdef _DEBUG # define DEBUG 1 # endif // _DEBUG -#endif // DEBUG +#endif // DEBUG // Standard exception class Error : public std::exception { @@ -242,6 +242,39 @@ inline bool c_isnan(float c) return d != d; } +//! Swap so that a<b +template<class T> inline void sort(T &a, T &b) +{ + if (a > b) + std::swap(a, b); +} + +//! Swap so that a<b<c +template<class T> inline void sort(T &a, T &b, T &c) +{ + if (a > b) + std::swap(a, b); + if (a > c) + std::swap(a, c); + if (b > c) + std::swap(b, c); +} + +//! Swap so that a<b<c<d +template<class T> inline void sort(T &a, T &b, T &c, T &d) +{ + if (a > b) + std::swap(a, b); + if (c > d) + std::swap(c, d); + if (a > c) + std::swap(a, c); + if (b > d) + std::swap(b, d); + if (b > c) + std::swap(b, c); +} + } // namespace Manta #endif |