public IEnumerator GetEnumerator() { StackElementLinkedList <T> current = _top; while (current != null) { yield return(current.getData()); current = current.getNext(); } }
public T pop() { if (_size == 0) { throw new InsufficientExecutionStackException("Stack empty"); } var data = _top.getData(); _top = _top.getNext(); _size--; return(data); }
public void push(T data) { if (_size >= _maxSize) { throw new StackOverflowException("Stack full"); } StackElementLinkedList <T> element = new StackElementLinkedList <T>(); element.setNext(data, _top); _top = element; _size++; }