Example #1
0
        public void Add(T data)
        {
            SimpleListItem <T> newItem =
                new SimpleListItem <T>(data);

            this._size++;

            if (tail == null)
            {
                this.head = newItem;
                this.tail = newItem;
            }
            else
            {
                this.tail.next = newItem;
                this.tail      = newItem;
            }
        }
Example #2
0
        public T Pop()
        {
            T Result = default(T);

            if (this.size == 0)
            {
                return(Result);
            }
            if (this.size == 1)
            {
                Result    = this.head.data;
                this.head = null;
                this.tail = null;
            }
            else
            {
                SimpleListItem <T> newTail = this.GetItem(this.size - 2);
                Result       = newTail.next.data;
                this.tail    = newTail;
                newTail.next = null;
            }
            this.size--;
            return(Result);
        }