From 7b1e93b596b09f3e6138ee67866e36766b6dc335 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 22 Apr 2006 02:49:27 +0000 Subject: Implement CLIP() routine used to put arbitrary value in specified range. svn-id: r22079 --- common/util.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'common') 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 inline T ABS (T x) { return (x>=0) ? x : -x; } template inline T MIN (T a, T b) { return (a inline T MAX (T a, T b) { return (a>b) ? a : b; } +template 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. -- cgit v1.2.3