Advertisement
Guest User

IteradorPares

a guest
Dec 10th, 2013
2,388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GAMBAS 0.71 KB | None | 0 0
  1. ' Gambas class file
  2.  
  3. Inherits Iterador
  4.  
  5. Private posicion As Integer = 0
  6.  
  7. Public Function currenItem() As Variant
  8.  
  9.   Return Super.getlista()[posicion]
  10.  
  11. End
  12.  
  13. Public Function primero() As Variant
  14.  
  15.   posicion = 1
  16.   Return currenItem()
  17.  
  18. End
  19.  
  20. Public Function siguiente() As Variant
  21.  
  22.   posicion += 2
  23.   If isdone() Then
  24.     Return currenItem()
  25.     ' Else
  26.     ' posicion = 0 'vuelvo a empezar...
  27.     ' Return currenItem()
  28.   Endif    
  29.  
  30. End
  31.  
  32. Public Function isdone() As Boolean
  33.   'hay siguiente?
  34.  
  35.   If posicion < Super.getlista().count Then        
  36.     'si, hay siguiente
  37.     Return True
  38.   Else              
  39.     'no, ya se ha acabado la lista...
  40.     Return False
  41.   Endif
  42.  
  43. End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement