public void Push(T element) { var newNode = new LinkedStackNode <T>(element) { NextNode = this.firstNode }; this.firstNode = newNode; this.Count++; }
public T Pop() { if (this.Count <= 0) { throw new InvalidOperationException("Stack is empty."); } var nodeToPop = this.firstNode; this.firstNode = this.firstNode.NextNode; this.Count--; return(nodeToPop.Value); }
public LinkedStackNode( T2 value, LinkedStackNode <T2> nextNode = null) { this.Value = value; }