This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: Java classes in Kawa
- From: Per Bothner <per at bothner dot com>
- To: Per Bothner <per at bothner dot com>
- Cc: Chris Bitmead <chris at bitmead dot com>, kawa <kawa at sources dot redhat dot com>
- Date: Wed, 10 Jul 2002 12:45:12 -0700
- Subject: Re: Java classes in Kawa
- References: <3D2C4140.2060201@bitmead.com> <3D2C7FE7.40005@bothner.com>
The attached patch allows Scheme lsist to be sorted.
--
--Per Bothner
per@bothner.com http://www.bothner.com/per/
Index: LList.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/lists/LList.java,v
retrieving revision 1.5
diff -u -r1.5 LList.java
--- LList.java 8 Apr 2002 19:29:01 -0000 1.5
+++ LList.java 10 Jul 2002 19:38:50 -0000
@@ -176,6 +176,33 @@
return ((Pair) next).car;
}
+ public Object getPrevious(int ipos, Object xpos)
+ {
+ int isAfter = (ipos & 1);
+ if (isAfter > 0)
+ {
+ xpos = xpos == null ? this : ((Pair) xpos).cdr;
+ }
+ else
+ {
+ if (xpos == null)
+ xpos = Empty;
+ }
+ if (xpos == Empty)
+ return eofValue;
+ return ((Pair) xpos).car;
+ }
+
+ protected void setPrevious(int ipos, Object xpos, Object value)
+ {
+ int isAfter = (ipos & 1);
+ if (isAfter > 0)
+ {
+ xpos = xpos == null ? this : ((Pair) xpos).cdr;
+ }
+ ((Pair) xpos).car = value;
+ }
+
public Object get (int index)
{
throw new ArrayIndexOutOfBoundsException (index);