public void Push(T element) { var next = new LinkedStackItem <T>(element); if (Last != null) { next.Previous = Last; } Last = next; Count++; }
public T Pop() { Count--; if (Last == null) { throw new InvalidOperationException(); } var result = Last.Value; Last = Last.Previous; return(result); }
public void Clear() { Count = 0; Last = null; }
public LinkedStackItem(T value) { Value = value; Previous = null; }