public T RemoveFromFront() { if (IsEmpty()) { throw new EmptyListException(name); } T removeItem = firstNode.Data; if (firstNode == lastNode) { firstNode = lastNode = null; } else { firstNode = firstNode.Next; } return(removeItem); }
public void Display() { if (IsEmpty()) { Console.WriteLine($"Empty {name}"); } else { Console.Write($"The {name} is: "); ListNode <T> current = firstNode; while (current != null) { Console.Write($"{current.Data} "); current = current.Next; } Console.WriteLine("\n"); } }
public List(string listName) { name = listName; firstNode = lastNode = null; }
public ListNode(T dataValue, ListNode <T> nextNode) { Data = dataValue; Next = nextNode; }