Esempio n. 1
0
        public IEnumerator GetEnumerator()
        {
            StackElementLinkedList <T> current = _top;

            while (current != null)
            {
                yield return(current.getData());

                current = current.getNext();
            }
        }
Esempio n. 2
0
        public T pop()
        {
            if (_size == 0)
            {
                throw new InsufficientExecutionStackException("Stack empty");
            }
            var data = _top.getData();

            _top = _top.getNext();
            _size--;
            return(data);
        }
Esempio n. 3
0
        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++;
        }