Ejemplo n.º 1
0
        public void Add(T element)
        {
            var newItem = new SimpleListItem <T>(element);

            this.Count++;

            if (last == null)
            {
                first = newItem;
                last  = newItem;
            }
            else
            {
                last.next = newItem;
                last      = newItem;
            }
        }
Ejemplo n.º 2
0
        public T Pop()
        {
            T current = default(T);

            if (Count == 0)
            {
                return(current);
            }
            if (Count == 1)
            {
                current = first.data;
                first   = null;
                last    = null;
            }
            else
            {
                SimpleListItem <T> newLast = GetItem(Count - 2);
                current      = newLast.next.data;
                last         = newLast;
                newLast.next = null;
            }
            Count--;
            return(current);
        }