/// <summary> /// /// </summary> /// <returns></returns> public IEnumerable <T> ToEnumerable() { var list = new List <T>(); SingleLinkedNode <T> current = Head; while (current != null) { list.Add(current.Data); current = current.Next; } return(list); }
/// <summary> /// /// </summary> public void Reverse() { SingleLinkedNode <T> current = Head; SingleLinkedNode <T> previous = null; while (current != null) { SingleLinkedNode <T> temp = current.Next; current.Next = previous; previous = current; current = temp; } Head = previous; }
/// <summary> /// /// </summary> /// <param name="p"></param> public void Push(T p) { SingleLinkedNode <T> node = new SingleLinkedNode <T> { Data = p }; if (Head == null) { Head = node; } else { SingleLinkedNode <T> current = Last; current.Next = node; } }