source: utilitiespy/tudelft/utilities/immutablelist/AbstractImmutableList.py@ 241

Last change on this file since 241 was 222, checked in by wouter, 4 years ago

#89 utilities to merge several modules. Added immutablelist

File size: 740 bytes
Line 
1from decimal import Decimal
2from typing import TypeVar
3
4from tudelft.utilities.immutablelist.ImmutableList import ImmutableList
5
6
7E = TypeVar('E')
8class ItemIterator:
9 def __init__(self, l:ImmutableList[E]):
10 # Team object reference
11 self._l = l
12 # member variable to keep track of current index
13 self._index = Decimal(0)
14 def __next__(self):
15 '''Returns the next value from team object's lists '''
16 if self._index >= self._l.size():
17 # End of Iteration
18 raise StopIteration
19 val=self._l.get(self._index)
20 self._index += Decimal(1)
21 return val
22
23class AbstractImmutableList(ImmutableList[E]):
24 def __iter__(self):
25 return ItemIterator(self)
Note: See TracBrowser for help on using the repository browser.