Sub Globals
Type Node (Id As Int, Largo As Int, Anterior As Node, Siguiente As Node)
Dim Raiz As Node
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
Raiz = CreaNodo(Rnd(1, 20))
End Sub
Sub Activity_Resume
For i = 0 To 1000 Step 1
InsertaNodo(Raiz, CreaNodo(Rnd(1,30)))
Next
ToastMessageShow ("Hecho!", True)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Private Sub InsertaNodo(NodoRaiz As Node, Nodo As Node)
Dim UltimoNodo As Node
UltimoNodo.Initialize
UltimoNodo = RetornaUltimoNodo(NodoRaiz)
UltimoNodo.Siguiente = Nodo
End Sub
Private Sub RetornaUltimoNodo(Nodo As Node) As Node
Dim UltimoNodo As Node
If Nodo.siguiente <> Null Then
UltimoNodo = RetornaUltimoNodo(Nodo.Siguiente)
Else
UltimoNodo = Nodo
End If
Return UltimoNodo
End Sub
Private Sub CreaNodo(Largo As Int) As Node
Dim NuevoNodo As Node
NuevoNodo.Initialize
NuevoNodo.Id = GetNewId
NuevoNodo.Largo = Largo
NuevoNodo.Anterior = Null
NuevoNodo.Siguiente = Null
Return NuevoNodo
End Sub
Private Sub GetNewId() As Int
Return Rnd(1, 100)
End Sub