整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
37
util/Math.h
Normal file
37
util/Math.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#ifndef D6937363_A08A_40BF_B387_36E8AC570ECF
|
||||
#define D6937363_A08A_40BF_B387_36E8AC570ECF
|
||||
/*
|
||||
*******************************************************************************
|
||||
* INCLUDE
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
namespace Util
|
||||
{
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CLASS DECLARE
|
||||
*******************************************************************************
|
||||
*/
|
||||
class Math
|
||||
{
|
||||
public:
|
||||
static unsigned alignup(unsigned num, unsigned align);
|
||||
static unsigned aligndown(unsigned num, unsigned align);
|
||||
|
||||
template <typename T> static T max(T a, T b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
template <typename T> static T min(T a, T b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
template <typename T> static T clamp(T value, T minVal, T maxVal)
|
||||
{
|
||||
return max(minVal, min(maxVal, value));
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue