예제 #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;
            }
        }