public void Pop() { if (head == null) { Console.WriteLine("stack is empty"); } else { head = head.next; } size--; }
private void Add(NodeStack <T> node) { NodeStack <T> current = node; if (head == null) { current.next = null; } else { current.next = head; } head = node; size++; }
public NodeStack(T newData) { data = newData; next = null; }
public void Push(T data) { NodeStack <T> node = new NodeStack <T>(data); Add(node); }
public StackList() { head = null; size = 0; }