1 // HtMaxMin
2 //
3 // macros and tools for computing max and min of values
4 //
5 // Part of the ht://Dig package   <http://www.htdig.org/>
6 // Copyright (c) 1999-2004 The ht://Dig Group
7 // For copyright details, see the file COPYING in your distribution
8 // or the GNU Library General Public License (LGPL) version 2 or later
9 // <http://www.gnu.org/copyleft/lgpl.html>
10 //
11 // $Id: HtMaxMin.cc,v 1.5 2004/05/28 13:15:20 lha Exp $
12 //
13 
14 #ifdef HAVE_CONFIG_H
15 #include "htconfig.h"
16 #endif /* HAVE_CONFIG_H */
17 
18 #include"HtMaxMin.h"
19 
20 unsigned int
max_v(unsigned int * vals,int n)21 HtMaxMin::max_v(unsigned int *vals,int n)
22 {
23     unsigned int maxv=vals[0];
24     for(int i=1;i<n;i++)
25     {
26 	unsigned int v=vals[i];
27 	if(v>maxv){maxv=v;}
28     }
29     return(maxv);
30 }
31 
32 unsigned short
max_v(unsigned short * vals,int n)33 HtMaxMin::max_v(unsigned short *vals,int n)
34 {
35     unsigned short maxv=vals[0];
36     for(int i=1;i<n;i++)
37     {
38 	unsigned short v=vals[i];
39 	if(v>maxv){maxv=v;}
40     }
41     return(maxv);
42 }
43 
44 unsigned int
min_v(unsigned int * vals,int n)45 HtMaxMin::min_v(unsigned int *vals,int n)
46 {
47     unsigned int minv=vals[0];
48     for(int i=1;i<n;i++)
49     {
50 	unsigned int v=vals[i];
51 	if(v<minv){minv=v;}
52     }
53     return(minv);
54 }
55 
56 unsigned short
min_v(unsigned short * vals,int n)57 HtMaxMin::min_v(unsigned short *vals,int n)
58 {
59     unsigned short minv=vals[0];
60     for(int i=1;i<n;i++)
61     {
62 	unsigned short v=vals[i];
63 	if(v<minv){minv=v;}
64     }
65     return(minv);
66 }
67