Commit d11b4c06cc1b6bd2c5ad604c8e49f9db477a668f

Authored by Erickson Silva
1 parent 7966df3e
Exists in master and in 1 other branch devel

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,6 +13,7 @@ class Iterator(object):
13 self.count = -1 13 self.count = -1
14 14
15 def load(self, lista): 15 def load(self, lista):
  16 + self.reset()
16 self.__list = list(lista); 17 self.__list = list(lista);
17 self.size = len(lista) 18 self.size = len(lista)
18 19
@@ -47,6 +48,10 @@ class Iterator(object): @@ -47,6 +48,10 @@ class Iterator(object):
47 def getAntT(self): 48 def getAntT(self):
48 return self.getToken("-")[1] 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 def hasNext(self): 55 def hasNext(self):
51 if(self.count < self.size-1): 56 if(self.count < self.size-1):
52 self.count += 1 57 self.count += 1