Commit d11b4c06cc1b6bd2c5ad604c8e49f9db477a668f
1 parent
7966df3e
Exists in
master
and in
1 other branch
Adiciona metodo 'getInterval' no Iterator
Showing
1 changed file
with
5 additions
and
0 deletions
Show diff stats
src/new/Iterator.py
| ... | ... | @@ -13,6 +13,7 @@ class Iterator(object): |
| 13 | 13 | self.count = -1 |
| 14 | 14 | |
| 15 | 15 | def load(self, lista): |
| 16 | + self.reset() | |
| 16 | 17 | self.__list = list(lista); |
| 17 | 18 | self.size = len(lista) |
| 18 | 19 | |
| ... | ... | @@ -47,6 +48,10 @@ class Iterator(object): |
| 47 | 48 | def getAntT(self): |
| 48 | 49 | return self.getToken("-")[1] |
| 49 | 50 | |
| 51 | + def getinterval(self, n): | |
| 52 | + if self.count+n > self.size: raise IndexError | |
| 53 | + return self.__list[self.count:self.count+n] | |
| 54 | + | |
| 50 | 55 | def hasNext(self): |
| 51 | 56 | if(self.count < self.size-1): |
| 52 | 57 | self.count += 1 | ... | ... |