This document contains code for a Public Class called Lista that defines a data structure for storing employee records. It includes properties and methods for managing a linked list, including adding and removing nodes. There are methods to get/set the head node, get the number of elements, add a node at a given position, and remove a node based on its position. The code implements a linked list to store employee records with properties like ID, name, address etc.
This document contains code for a Public Class called Lista that defines a data structure for storing employee records. It includes properties and methods for managing a linked list, including adding and removing nodes. There are methods to get/set the head node, get the number of elements, add a node at a given position, and remove a node based on its position. The code implements a linked list to store employee records with properties like ID, name, address etc.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
This document contains code for a Public Class called Lista that defines a data structure for storing employee records. It includes properties and methods for managing a linked list, including adding and removing nodes. There are methods to get/set the head node, get the number of elements, add a node at a given position, and remove a node based on its position. The code implements a linked list to store employee records with properties like ID, name, address etc.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
Public Class listaestatica Structure Reg_Empieado Mía cédula As Long
Diin nombre As String Dim dirección As String Dirá Artefacto As String Dirá Marca As String Dim modelo As String Dim Fecha de IngresoAs String Dim Precio As Double End Structure Prívate Const man As Integer = 50 Prívate vlistaest (rnax) As Reg_Empleado Prívate vnumeleiti As Integer Public Property numelem{) As Integer Ser nuinelem = vnurnelern End Get Set(ByVal valor As Integerj vnumelem = valor End Set End Property Public Property listal(ByVal ind As Integer} As Reg_Empleado Get listal = vlistaest(ind) End Get Set(8yVal valor As RegJEmpleado) vlistaest(ind) = valor End Set End Property Public Sub New() vnumelem = O End Sub Public Function ponerestatico(ByVal pos As Integer, ByVal dato As .Reg_Empleado) As Boolean ponerestatico = Trae *^^59Í"is€aes1;Tvn'tatieleit'j = "datio* - - vnumelem-.+==--1____________----- _____________:___;_____________i_____ Elself vnumelem < max And pos <= XTiuroelerri Then recorrerestÍTrue, pos) vlistaest(POS¡ = dato vnumelem += 1
ponerestatico = r'alse End If
End Function Prívate Sub recorrerest(ByVal derecha As Boolean, Byval posición As Inteorer) Dim i As Integer If derecha Then For i = vnumelem To posición Step -1 vlistaest(i + 1} = vlistaest(i) Next i El se For i = posición To vnumelem vlistaest(i) = vlistaest(i + 1} Next i End If End Sub Public Function sacarestatico(ByVal pos As Integer, ByVal dato As Reg_Empleado) As Boolean sacarestatico = Trae If vnumelem > O Then If pos >= vnumelem Then dato = vlistaest(vnumelem - 1) Else dato = vlistaest(pos) recorrerest(False, pos) vnumelem -= 1 End If Else sacarestatico = False End If End Function Si) ci d^ss
Public Class Lista
Private vCab As New Nodol Prívate vnumelem As Intl6 Public Property Cab() As Nodol Get Return vCáb End Get Set(ByVal valor As Nodol) vCab = valor End Set End Propertv Public Property numelem(j As Intl6 Get Return vnumelem End Get Set ¡ByVal valor As IntlS) vnumelem = valor Er¿d Set End Property Public Sufo poner{ByVal pos As Intl6, ByVal Rg_dato As. Reg_Empleado) Diin Nuevo As New Nodol Dim aux As Nodol Dim i As Intl6 Nuevo.inf = Rg_dato If vnumelem = O Then vCab = Nuevo Elself pos > vnumelem Then aux = vCab For i = 2 To vnumelem aux = aux.otro Next. aux.otro = Nuevo Elself pos <= vnumelem Then If pos = 1 Then Nuevo.otro = Cab Cab = Nuevo Else aux = vCab For i = 2 To pos - 1 aux = aux.otro Hex-t Nuevo,otro = aux.otro aux.otro = Nuevo ...... ---—^-Éhá^ff^" _______:_;__ vnumelem.+p 1 . ......________________________......_____„.___ Public Sub lííf'w {} vnumelem = O
Prívate runction Recorre (ayVal pos As integer} As Nodol
Diin i As InteQer Recorre = vCab For i = 1 To pos = 1 Recorre = Recorre.otro Next i End Function Public Function sacar(ByVal pos As Integer, ByVal Rg_dato As Reg_Empleado) As Boolean Dirá tmp As New Nodol Dirá aux As New Nodol sacar = False If vnumelem > O Then If pos = 1 Then Rg_dato = vCab.inf tmp = vCab vCab = vCab.otro tmp = Nothing El.se If pos >= vnumelem Then aux = recorrer(vnumelem - 1) Rg_dato = aux,otro,inf aux.otro = Nothing El se aux = recorrer(pos - 1} tmp = aux.otro Rg_dato = tmp.inf aux.otro = aux.otro tmp = Nothing End If End If vnumelem = vnumelem - 1 End If End Function Privare Function recorrer(ByVal pos As Integer) As Nodol Dim i As Integer recorrer = vCab For i = 2 To pos = 1 recorrer = recorrer.otro Next i £jnci ruiiCuron End Class 3tgB _Pu.'"^~L.iL-c ^OO^^J-S I^crirsso - • -• -=-- -"- ; Public - i As iTitie : _____ . Puolic f.As. Int6_4____ Public Control Arreglos As New Lista ¿: xi o ixi o cm j, €. ¿:"srtx£_i. ^j_ciss .racimas ij-LSta^-Lnaiürca Inherits System.Web.UI.Page
Protected Sub ButtonIngresar_Click(oyVal senaer As Object, ByVal e As
System.EventArgs) Handles Buttonlngresar.Click Dim rgp As New Reg_Empleado Dim pos As Integer pos = Val itxtposicion.Text} rgp.Cédula = TextBoxCedula.Text rgp.Nombre = TextBoxNombre.Text rgp.Dirección = TextBoxDireccion.Text rgp. Artefacto = TextBoxArtefacto.Text rgp. Marca = TextBoxMarca.Text rgp.Modelo = TextBcxModelo.Text rgp.fechadeingreso = TextBoxfechadeingreso.Text rgp.Precio = TextBoxPrecio.Text Control_Arreglos.poner(pos, rgp) TextBoxCedula.Text=" "; TextBoxNombre. Text=" " ; TextBoxMreccion.Text=" "; TextBoxArtefacto.Text=" "; TextBoxMarca.Text=" "; TextBoxModelo.Text=" "; TextBoxfechadeingreso. Text=" '•'; TextBoxPrecio.Text=" "; txtposicion.Focus() End Sub Protected Sub ButtonMostrar_Click(ByVal sender As Object, ByVal e As System. EventArgs} Handles ButtonMostrar.Click Dim i As Intie Dim aux As Nodol Istmostrar.ítems.Clear{) aux = Control_Arreglos.Cab Fcr i = 1 T'o Control_Arreglos.numelem Istmostrar.ítems.Add(aux.inf.Cédula.ToString() + " " + ^ux.inf .Nombre. ToString (} •¥ " " -f aux. inf. Dirección. ToString () 4- " " 4-aux. inf. Artefacto. ToString (} + " " + aux. inf .Marca. ToString ()+ " !! + aux.inf.Modelo.ToString()+ " " + aux.inf.fechadeingreso.ToString{j+• " " + aux.inf.Precio.ToStringí)) aux = aux.otro
Jrrotected Sub ButtonSacar_Click (ByVal sencier As Object, syVal e As
System.EventArgs) Kandles ButtonSacar.Click Diiu i As Intecfei: Dirá -rgp As New Reg Empleado Dim aux Ks New Noció 1 i = Val(TextBoxNodoSacar.Text) Control_Arreglos.sacar(i, rgp) End Sub