from decimal import Decimal from typing import TypeVar from tudelft.utilities.immutablelist.ImmutableList import ImmutableList E = TypeVar('E') class ItemIterator: def __init__(self, l:ImmutableList[E]): # Team object reference self._l = l # member variable to keep track of current index self._index = Decimal(0) def __next__(self): '''Returns the next value from team object's lists ''' if self._index >= self._l.size(): # End of Iteration raise StopIteration val=self._l.get(self._index) self._index += Decimal(1) return val class AbstractImmutableList(ImmutableList[E]): def __iter__(self): return ItemIterator(self)