private static void TestValueTypeQueue(IEnumerableQueue <int> queue) { for (int i = 0; i < 18; i++) { queue.Enqueue(i); } Console.WriteLine("Add range 0-17."); PrintCollection(queue); queue.Dequeue(); queue.Dequeue(); queue.Dequeue(); Console.WriteLine("Dequeued 3 items."); PrintCollection(queue); for (int i = 8; i < 12; i++) { queue.Enqueue(i); } Console.WriteLine("Enqueued range 8-11."); PrintCollection(queue); for (int i = 0; i < 15; i++) { queue.Dequeue(); } Console.WriteLine("Dequeued 15 items."); PrintCollection(queue); for (int i = 8; i < 12; i++) { queue.Enqueue(i); } Console.WriteLine("Enqueued range 8-11."); PrintCollection(queue); for (int i = 0; i < 5; i++) { queue.Dequeue(); } Console.WriteLine("Dequeued 5 items."); PrintCollection(queue); }
private static void TestReferenceTypeQueue(IEnumerableQueue <string> queue) { for (char i = 'a'; i < 'a' + 18; i++) { queue.Enqueue(i.ToString()); } Console.WriteLine("Add range a-r."); PrintCollection(queue); queue.Dequeue(); queue.Dequeue(); queue.Dequeue(); Console.WriteLine("Dequeued 3 items."); PrintCollection(queue); for (char i = 'o'; i < 'o' + 4; i++) { queue.Enqueue(i.ToString()); } Console.WriteLine("Enqueued range o-r."); PrintCollection(queue); for (int i = 0; i < 15; i++) { queue.Dequeue(); } Console.WriteLine("Dequeued 15 items."); PrintCollection(queue); for (char i = 'o'; i < 'o' + 4; i++) { queue.Enqueue(i.ToString()); } Console.WriteLine("Enqueued range o-r."); PrintCollection(queue); for (int i = 0; i < 5; i++) { queue.Dequeue(); } Console.WriteLine("Dequeued 5 items."); PrintCollection(queue); }