示例#1
0
        public int Dequeue()
        {
            if (head == null)
            {
                throw new InvalidOperationException();
            }
            var result = head.Value;

            head = head.Next;
            if (head == null)
            {
                tail = null;
            }
            return(result);
        }
示例#2
0
        public void Enqueue(int value)
        {
            var item = new MyQueueItem {
                Value = value
            };

            if (head == null)
            {
                head = tail = item;
            }
            else
            {
                tail.Next = item;
                tail      = item;
            }
        }