static void Main() { CustomQueue <int> queue = new CustomQueue <int>(); queue.Enqueue(10); queue.Enqueue(20); queue.Enqueue(30); queue.Enqueue(40); queue.Enqueue(50); foreach (var item in queue) { Console.WriteLine(item); } Console.WriteLine("Dequeue(): {0}", queue.Dequeue()); Console.WriteLine("Dequeue(): {0}", queue.Dequeue()); Console.WriteLine("Dequeue(): {0}", queue.Dequeue()); foreach (var item in queue) { Console.WriteLine(item); } Console.WriteLine("Peek(): {0}", queue.Peek()); Console.WriteLine("Peek(): {0}", queue.Peek()); foreach (var item in queue) { Console.WriteLine(item); } }
static void Main(string[] args) { ICustomQueue <int> queue = new CustomQueue <int>(); queue.Enqueue(1); queue.Dequeue(); queue.Enqueue(1); foreach (var item in queue) { Console.WriteLine(item); } Console.WriteLine(queue.Count); }
public bool MoveNext() { switch (state) { case 0: i = 0; state = 1; goto case 1; case 1: if (!(i < source.Count)) { state = 0; return(false); } current = source.Peek(); source.Enqueue(source.Dequeue()); state = 2; return(true); case 2: ++i; goto case 1; } return(false); }