private void SetHeadAndTail(T data) { var item = new ItStack <T>(data); Head = item; Tail = item; Count++; }
public void Push(T data) { var item = new ItStack <T>(data) { Previous = Head }; Head = item; Count++; }
public T Pop() { if (Count > 0) { var item = Head; Head = Head.Previous; Count--; return(item.Data); } else { throw new NullReferenceException(); } }
public void Clear() { Head = default; Tail = default; Count = 0; }
public Stack() { Tail = default; Head = default; Count = 0; }