Ejemplo n.º 1
0
 public void ClearAll()
 {
     if (sLinkedList.head != null)
     {
         while (sLinkedList.head != null)
         {
             SNode <T> firstNode = sLinkedList.head;
             sLinkedList.head = firstNode.next;
             firstNode        = null;
         }
     }
 }
Ejemplo n.º 2
0
        public void Insert(T newData)
        {
            SNode <T> newNode = new SNode <T>(newData);

            if (sLinkedList.head == null)
            {
                sLinkedList.head = newNode;
            }
            else
            {
                SNode <T> last = FindLast(sLinkedList);
                last.next = newNode;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Return all data as a List
        /// </summary>
        /// <returns></returns>
        public List <T> GetAll()
        {
            List <T> list = new List <T>();

            if (sLinkedList.head != null)
            {
                SNode <T> current = sLinkedList.head;
                while (current != null)
                {
                    list.Add(current.data);
                    current = current.next;
                }
            }

            return(list);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Console output
 /// </summary>
 public void DisplayAll()
 {
     if (sLinkedList.head == null)
     {
         Console.WriteLine("List is empty!");
     }
     else
     {
         SNode <T> current = sLinkedList.head;
         while (current != null)
         {
             Console.WriteLine(current.data);
             current = current.next;
         }
     }
 }
Ejemplo n.º 5
0
 public SNode(T _data)
 {
     data = _data;
     next = null;
 }