aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2006-04-22 02:49:27 +0000
committerEugene Sandulenko2006-04-22 02:49:27 +0000
commit7b1e93b596b09f3e6138ee67866e36766b6dc335 (patch)
tree8c4c2e1fb5205d23f238af2122f33b6d03a653db
parent1a605b2760f228ff0b14c3d9655f70d108e03c23 (diff)
downloadscummvm-rg350-7b1e93b596b09f3e6138ee67866e36766b6dc335.tar.gz
scummvm-rg350-7b1e93b596b09f3e6138ee67866e36766b6dc335.tar.bz2
scummvm-rg350-7b1e93b596b09f3e6138ee67866e36766b6dc335.zip
Implement CLIP() routine used to put arbitrary value in specified range.
svn-id: r22079
-rw-r--r--common/util.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/common/util.h b/common/util.h
index 83ba73c30f..c55bee6c1d 100644
--- a/common/util.h
+++ b/common/util.h
@@ -37,6 +37,8 @@
template<typename T> inline T ABS (T x) { return (x>=0) ? x : -x; }
template<typename T> inline T MIN (T a, T b) { return (a<b) ? a : b; }
template<typename T> inline T MAX (T a, T b) { return (a>b) ? a : b; }
+template<typename T> inline T CLIP (T v, T amin, T amax)
+ { if (v < amin) return amin; else if (v > amax) return amax; else return v; }
/**
* Template method which swaps the vaulues of its two parameters.