> Try using a Python list object:
The problem is that I've just used the ArrayList for some
of java's sorting capabilities...
I don't want to copy the Array List to a python list before
extracting the first two values.
Here's a more complete code snippet.
Jim
class ImageCountsDescendingComparator (java.util.Comparator):
def compare(self, ic1, ic2):
difference =3D ic2.accessCount  ic1.accessCount
return int(difference)
class imageStatsImagePie(HttpServlet):
def doGet(self, request, response):
# create our sorter
sortCountDescending =3D ImageCountsDescendingComparator()
accessList =3D java.util.ArrayList(filesAccesses.values())
java.util.Collections.sort(accessList, sortCountDescending)
# add all the accesses to the time series by minute
for counts in accessList[0:maxFiles]:
data.setValue(counts.imageName,
java.lang.Long(counts.accessCount))
> Original Message
> From: Chris van Mels [mailto:cvanmels@...]=20
> Sent: Wednesday, June 11, 2003 9:37 AM
> To: 'jythonusers@...'
> Subject: RE: [Jythonusers] Slice on an ArrayList needs integer what?
>=20
>=20
> Try using a Python list object:
>=20
> >>>al=3D[]
> >>>al.append("one")
> >>>al.append("two")
> >>>al.append("three")
> >>>al
> ['one', 'two', 'three']
>=20
> >>>al[0:2]
> >>>['one', 'two']
>=20
>  Chris
>=20
> > 
> > From: James Carroll[SMTP:jim@...]
> > Sent: Wednesday, June 11, 2003 9:27 AM
> > To: jythonusers@...
> > Subject: [Jythonusers] Slice on an ArrayList needs integer what?
> >=20
> >=20
> > I'm trying to do a slice on an ArrayList... (see below) =20
> What's the best
> > way to get just the first few elements of the list?
> >=20
> > Why is it giving the error 'only integer keys accepted?'
> >=20
> > And finally, what's your favorite Jython book so far for=20
> understanding
> > these subtleties?
> >=20
> > Thanks!
> > Jim
> >=20
> >=20
> > >>> al =3D java.util.ArrayList()
> > >>> al.add("one")
> > 1
> > >>> al.add("two")
> > 1
> > >>> al.add("three")
> > 1
> > >>> al
> > [one, two, three]
> > >>> al[0:2]
> > Traceback (innermost last):
> > File "<console>", line 1, in ?
> > TypeError: only integer keys accepted
> > >>>
> >=20
> >=20
> > 
> > This SF.net email is sponsored by: Etnus, makers of=20
> TotalView, The best
> > thread debugger on the planet. Designed with thread=20
> debugging features
> > you've never dreamed of, try TotalView 6 free at http://www.etnus.com.
> > _______________________________________________
> > Jythonusers mailing list
> > Jythonusers@...
> > https://lists.sourceforge.net/lists/listinfo/jythonusers
> >=20
>=20
>=20
> 
> This SF.net email is sponsored by: Etnus, makers of=20
> TotalView, The best
> thread debugger on the planet. Designed with thread debugging features
> you've never dreamed of, try TotalView 6 free at http://www.etnus.com.
> _______________________________________________
> Jythonusers mailing list
> Jythonusers@...
> https://lists.sourceforge.net/lists/listinfo/jythonusers
>=20
