2 * Description: Global package for comparison.
4 * @ Author Create/Modi Note
5 * Xiaofeng Xie Jun 15, 2002 xiaofengxie@tsinghua.org.cn
13 package net
.adaptivebox
.global
;
15 public class GlobalCompare
{
17 /* compare the data1 and data2, if data1=data2, return 0
18 * if data1 < data2, return LESS_THAN, else if data1 > data2, LARGER_THAN
20 static public int compare(double data1
, double data2
) {
22 return CompareValue
.LESS_THAN
;
23 else if (data1
> data2
)
24 return CompareValue
.LARGER_THAN
;
26 return CompareValue
.EQUAL_TO
;
29 /* check the magnitude of two array, the frontial is more important
31 public static int compareArray(double[] fit1
, double[] fit2
) {
32 if (fit1
.length
!=fit2
.length
) {
33 return CompareValue
.INVALID
; //error
35 for (int i
=0; i
<fit1
.length
; i
++) {
36 if (fit1
[i
]>fit2
[i
]) {
37 return CompareValue
.LARGER_THAN
; //Large than
38 } else if (fit1
[i
]<fit2
[i
]){
39 return CompareValue
.LESS_THAN
; //Less than
42 return CompareValue
.EQUAL_TO
; //same