示例#1
0
        public void Enqueue(T data)
        {
            var node = new MyLinkedListQueueNode <T>(data);

            if (_head == null)
            {
                _tail = _head = node;
            }
            else
            {
                _head.Next = node;
                _head      = node;
            }
            Count++;
        }
示例#2
0
        public T Dequeue()
        {
            if (_tail == null)
            {
                throw new InvalidOperationException();
            }

            var data = _tail.Data;

            _tail = _tail.Next;
            Count--;

            if (_tail == null)
            {
                _head = null;
            }

            return(data);
        }