Exemplo n.º 1
0
        public void Push(T element)
        {
            var next = new LinkedStackItem <T>(element);

            if (Last != null)
            {
                next.Previous = Last;
            }

            Last = next;
            Count++;
        }
Exemplo n.º 2
0
        public T Pop()
        {
            Count--;
            if (Last == null)
            {
                throw new InvalidOperationException();
            }

            var result = Last.Value;

            Last = Last.Previous;
            return(result);
        }
Exemplo n.º 3
0
 public void Clear()
 {
     Count = 0;
     Last  = null;
 }
Exemplo n.º 4
0
 public LinkedStackItem(T value)
 {
     Value    = value;
     Previous = null;
 }