#!/usr/bin/python
import sys
class rlist(list):
def __init__(self, ls=[]):
list.__init__(self, ls)
self.current = 0
def next(self):
if self.current < len(self):
self.current += 1
else:
self.current = 0
return self.current
def __delitem__(self, i):
list.__delitem__(self, i)
if i < self.current:
if self.current != 0:
self.current -= 1
else:
# FIXME: Move backward on delete?
self.current = len(self)
elif i == self.current:
# FIXME: point to next or previous? overflow?
self.current == self.current
def main():
b = rlist(range(10))
print b
print 'next', b.next()
print 'next', b.next()
print 'next', b.next()
print 'item', b[b.current]
print 'current:', b.current
del b[2]
print 'delete 2'
print b
print 'current:', b.current
print 'item', b[b.current]
print 'next', b.next()
print 'item', b[b.current]
print b
if __name__ == '__main__':
main()
# vim:ts=8:sw=4:expandtab