public int Dequeue() { if (head == null) { throw new InvalidOperationException(); } var result = head.Value; head = head.Next; if (head == null) { tail = null; } return(result); }
public void Enqueue(int value) { var item = new MyQueueItem { Value = value }; if (head == null) { head = tail = item; } else { tail.Next = item; tail = item; } }