01: package elf;
02:
03: /**
04: A Comparator, for activities like sorting, that lets a procedure do
05: the work of comparing.
06: **/
07:
08: public class SchemeComparator implements java.util.Comparator {
09: jsint.Procedure proc;
10:
11: public SchemeComparator(jsint.Procedure proc) {
12: this .proc = proc;
13: }
14:
15: public int compare(Object a, Object b) {
16: return jscheme.JScheme.intValue(jscheme.JScheme
17: .forCurrentEvaluator().call(proc, a, b));
18: }
19:
20: public boolean equals(Object that) {
21: return this == that || this .getClass() == that.getClass()
22: && this .proc == ((SchemeComparator) that).proc;
23: }
24:
25: public int hashCode() {
26: return proc.hashCode();
27: }
28: }
|