org.hecl
Class Compare
- java.lang.Object
-
- org.hecl.Compare
-
public class Compare extends java.lang.ObjectTheCompareclass exists to compare things in different ways.
-
-
Field Summary
Fields Modifier and Type Field and Description static intNUMCOMPAREstatic intPROCCOMPAREstatic intSTRINGCOMPARE
-
Constructor Summary
Constructors Constructor and Description Compare()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static intcompareProc(Thing a, Thing b, Interp interp, Thing sortproc)ThecompareProcmethod takes two things to compare, an interpreter, andthe name of a proc to compare the two things with.static intcompareString(Thing a, Thing b)compareStringcompares two Things as strings.static booleansame(Thing t1, Thing t2)samechecks if two Things as the same.
-
-
-
Field Detail
-
NUMCOMPARE
public static final int NUMCOMPARE
- See Also:
- Constant Field Values
-
STRINGCOMPARE
public static final int STRINGCOMPARE
- See Also:
- Constant Field Values
-
PROCCOMPARE
public static final int PROCCOMPARE
- See Also:
- Constant Field Values
-
-
Method Detail
-
same
public static boolean same(Thing t1, Thing t2)
samechecks if two Things as the same. In case the parameters areObjectThings, they are the same only if they are identical, for all otherThings this function callscompareStringto check for sameness.This subtle difference in comparison is necessary since
ObjectThing.toString()may yield the same string representation even when the objects are different (happens i.e. on Nokia 6630 for instances ofjavax.microeditoion.lcdui.Command.- Parameters:
t1- aThingvaluet2- aThingvalue- Returns:
booleanindicating sameness.
-
compareString
public static int compareString(Thing a, Thing b)
compareStringcompares two Things as strings. This can't fail, because all Things may be represented as strings.- Parameters:
a- aThingvalueb- aThingvalue- Returns:
- an
intvalue
-
compareProc
public static int compareProc(Thing a, Thing b, Interp interp, Thing sortproc) throws HeclException
ThecompareProcmethod takes two things to compare, an interpreter, andthe name of a proc to compare the two things with. It puts together a codething, runs it, and returns the result: 0 if the two things are equal, -1 if A is "less than" B, and 1 if 1 if A is "greater than" B.- Parameters:
a- aThingvalueb- aThingvalueinterp- anInterpvaluesortproc- aThingvalue- Returns:
- an
intvalue - Throws:
HeclException- if an error occurs
-
-
DataMelt 3.0 © DataMelt by jWork.ORG