Hi
Am 31.10.2013 23:35, schrieb Terry Reedy:
On 10/31/2013 5:29 PM, Ulrich Goebel wrote:
I'm locking for an "iterator" type with not only the .next() method, but
with a .previous(), .first() and .last() method, so that I can through
it from the beginning or from the end, and in both directions, even
alternately (for example two steps forward, one backward, two steps
forward).
You are free to write such a class, if it is appropriate for your actual
use case.
Ok, possibly I will try that later...
If you have a concrete sequence object seq with random access, there is
no reason to do so. First and last are seq[0] and seq[-1]. Given
'cursor' i, prev and next are 'i-=1;seq[i]' and 'i+=1;seq[i]'.
That gives me the solution. What I have, is an iterator object comming
as a SQLite database cursor object. So I could minimize the underliying
SELECT and build index = list(cursor). Then with Your hints I get what I
want.
Thanks
Ulrich
--
Ulrich Goebel
Paracelsusstr. 120, 53177 Bonn
--
https://mail.python.org/mailman/listinfo/python-list