Advertisement
jsbsan

Nodo lista enlazada

Apr 18th, 2014
1,646
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GAMBAS 0.92 KB | None | 0 0
  1. ' Gambas class file
  2.  
  3. Private hdato As String
  4. Property dato As String
  5.  
  6. Private hsiguiente As Nodo
  7. Property siguiente As Nodo
  8.  
  9. Public Sub _new(dat As String, Optional prox As Nodo)
  10.  
  11.   hdato = dat
  12.   hsiguiente = prox
  13.  
  14. End
  15.  
  16. Public Sub EnlaceHaciaAdelante(prox As Nodo)
  17.  
  18.   hsiguiente = prox
  19.  
  20. End
  21.  
  22. Private Function dato_Read() As String  
  23.  
  24.   Return hdato    
  25.  
  26. End
  27.  
  28. Private Sub dato_Write(Value As String)
  29.  
  30.   hdato = Value  
  31.  
  32. End
  33.  
  34. Private Function siguiente_Read() As Nodo  
  35.  
  36.   Return hsiguiente  
  37.  
  38. End
  39.  
  40. Public Function VerLista() As String
  41.  
  42.   Dim frutas As String
  43.   Dim un_nodo As Nodo
  44.  
  45.   un_nodo = Me
  46.   While True
  47.     un_nodo = un_nodo.siguiente  
  48.     If IsNull(un_nodo) Then
  49.       Break
  50.     Endif
  51.    
  52.     frutas &= un_nodo.dato & "<br>"
  53.    
  54.   Wend        
  55.  
  56.   Return frutas
  57.  
  58. End
  59.  
  60. Private Sub siguiente_Write(Value As Nodo)
  61.  
  62.   hsiguiente = Value  
  63.  
  64. End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement