This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: SRFI-14 progress
- From: Per Bothner <per at bothner dot com>
- To: Jim White <jim at pagesmiths dot com>
- Cc: "'Kawa List'" <kawa at sources dot redhat dot com>
- Date: Sat, 18 Jun 2005 11:23:36 -0700
- Subject: Re: SRFI-14 progress
- References: <42B45536.8080501@pagesmiths.com>
Jim White wrote:
I've got a working (but not yet packaged and suitably ready for prime
time) implementation of SRFI-14 for Kawa.
Thanks for working on this!
It appears the representation is a list of ranges where each range is
represented as cons. member? is implemented by linearly searching the
list. I don't that is a good idea.
However, if we replace the list by a vector then we can use binary
search to implement member? which might work quite well. For even
better performance we can use a primitive Java <int> array.
Ultimatately, it might be good to write this class in Java, so it can be
used by the Scheme reader - and other Kawa implementations. I don't
know if that is actually useful, but a hybrid implementation might make
it easy to convert:
public class CharSetUsingRanges {
int numRanges;
int[] ranges;
public final int rangeLow (int i) { return ranges[2*i]; }
public final int rangeHigh (int i) { return ranges[2*i+1]; }
public CharSetUsingRanges (int lo, int hi)
{
ranges = new int[2];
ranges[0] = lo;
ranges[1] = hi;
numRanges = 1;
}
}
Then the actual code can be written in Scheme, but if at some point in
the future we/I decide it would be useful to use this class from the
Java core then it will be easy to convert them to Java.
Untimately, I think a CharSet class should be part of standard Java, but
that is a different discussion.
--
--Per Bothner
per@bothner.com http://per.bothner.com/