internal ListNode <T> GetLastNode(SingleList <T> singlyList) { ListNode <T> temp = singlyList.Head; while (temp.Next != null) { temp = temp.Next; } return(temp); }
public void InvertirLista(SingleList <int> singlyList) { ListNode <int> prev = null; ListNode <int> current = singlyList.Head; ListNode <int> temp = null; while (current != null) { temp = current.Next; current.Next = prev; prev = current; current = temp; } singlyList.Head = prev; }
public void Cargar(SingleList <int> vectors) { Console.Write("\n"); Console.WriteLine("\n Metodo de Burbuja"); SingleList <int> listaDeEnteros = new SingleList <int>(); listaDeEnteros = vectors; vector = new int[listaDeEnteros.Count]; for (int f = 0; f < listaDeEnteros.Count; f++) { vector[f] = listaDeEnteros.Head.Value; listaDeEnteros.Head = listaDeEnteros.Head.Next; } MetodoBurbuja(); Imprimir(); }
public void AddNodeFinal(SingleList <T> singlyList, T value) { ListNode <T> newNode = new ListNode <T>(value, Head.Position); if (singlyList.Head == null) { this.Current = Head; this.Current.Next = Current; this.Head = newNode; this._count++; return; } ListNode <T> lastNode = GetLastNode(singlyList); lastNode.Next = newNode; }
public void SearchNode(SingleList <int> singlyList, int value) { ListNode <int> temp = singlyList.Head; while (temp != null) { if (temp.Value == value) { //Console.WriteLine("El elemento {0} está presente en la lista", value); Console.WriteLine("El elemento {0} está presente en la lista en la posición {1}", value, temp.Position); return; } temp = temp.Next; } Console.WriteLine("El elemento {0} NO está presente en la lista", value); }