예제 #1
0
        public T Pop()
        {
            T Result = default(T);

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