public void PrimeAnagram_Queue_linkedList_Method() { QueueLL <T> QLL = Utility.CreateQueueLL <T>(); string str1 = string.Empty; string str2 = string.Empty; for (int i = 2; i <= 1000; i++) { if (Utility.IsPrime(i)) { for (int j = 0; j <= 1000; j++) { if (Utility.IsPrime(j) && i != j) { str1 = i.ToString(); str2 = j.ToString(); if (!Utility.SearchItem(QLL.Front, str1)) { if (Utility.CheckAnagram(str1, str2)) { Utility.EnqueQLL(QLL, (T)((object)str1)); } } } } } } Utility.PrintQLL(QLL); }
static void TestQueue(IQueue <int> queue) { Console.WriteLine("should be true:{0}", queue.IsEmpty()); queue.Enqueue(1); queue.Enqueue(2); queue.Enqueue(3); Console.WriteLine("should be false:{0}", queue.IsEmpty()); Console.WriteLine("should be 1:{0}", queue.Peek()); Console.WriteLine("should be 1:{0}", queue.Dequeue()); Console.WriteLine("should be 2:{0}", queue.Peek()); queue.Clear(); Console.WriteLine("should be true:{0}", queue.IsEmpty()); queue.Dequeue(); QueueLL <int> queuell = new QueueLL <int>(); Console.WriteLine("should be true:{0}", queuell.IsEmpty()); queuell.Enqueue(1); queuell.Enqueue(2); queuell.Enqueue(3); Console.WriteLine("should be false:{0}", queuell.IsEmpty()); Console.WriteLine("should be 1:{0}", queuell.Peek()); Console.WriteLine("should be 1:{0}", queuell.Dequeue()); Console.WriteLine("should be 2:{0}", queuell.Peek()); queuell.Clear(); Console.WriteLine("should be true:{0}", queuell.IsEmpty()); queuell.Dequeue(); }