internal static void Main() { Queue<int> queue = new Queue<int>(Max); for (int i = 0; i < 2 * Max; i++) { queue.Put(i); int itemInFront = queue.Get(); Console.Write("{0} ", itemInFront); } //// Това ще причини препълване при последното включване ////for (var i = 0; i < Max + 1; i++) ////{ //// queue.Put(i); ////} //// Това ще причини грешка при последното изключване, тъй като опашката е празна ////for (var i = 0; i < Max; i++) ////{ //// queue.Put(i); ////} ////for (int i = 0; i < Max + 1; i++) ////{ //// queue.Get(); ////} }
public frmMain() { InitializeComponent(); queueMain = new Queue(this.containerMain.Panel1); checkStatusQueue(); }
public void StandardExeption_2() { Queue.Queue queue = new Queue.Queue(); for (int i = 0; i < 101; ++i) { queue.enqueue(0, 0); } }
public void Test() { Queue<int> queue=new Queue<int>(); queue.Enqueue(2); queue.Enqueue(3); Console.WriteLine(queue.Empty); Console.WriteLine(queue.Dequeue()); Console.WriteLine(queue.Front); Console.WriteLine(queue.Dequeue()); Console.WriteLine(queue.Empty); }
public void StandartTest_2() { Queue.Queue queue = new Queue.Queue(); for (int i = 0; i < 100; ++i) { queue.enqueue(99 - i, 99 - i); } for (int i = 100 - 1; i > 0; --i) { var a = queue.dequeue(); Assert.AreEqual(i, a); } }
public void StandartTest_1() { Queue.Queue queue = new Queue.Queue(); for (int i = 0; i < 100; ++i) { queue.enqueue(i, i); } for (int i = 100 - 1; i > 0; --i) { var a = queue.dequeue(); Assert.AreEqual(i, a); } }
static void Main(string[] args) { var queue = new MyQueue<int>(1); var queu2 = new Queue<int>(); queue.Enqueue(3); queue.Enqueue(5); queue.Enqueue(4); System.Console.WriteLine(queue.Peek()); System.Console.WriteLine(queue.Dequeue()); System.Console.WriteLine(queue.Dequeue()); }
static void Main() { var testingQueue = new Queue<int>(); for (int i = 1; i <= 10; i++) { testingQueue.Enqueue(i); } do { Console.WriteLine("{0} -- Length: {1}", testingQueue.Dequeue(), testingQueue.Length); } while (testingQueue.Length != 0); }
public void StandartTest_3() { Queue.Queue queue = new Queue.Queue(); queue.enqueue(6, 6); queue.enqueue(3, 3); queue.enqueue(2, 2); queue.enqueue(4, 4); queue.enqueue(5, 5); queue.enqueue(1, 1); for (int i = 6; i > 0; --i) { var a = queue.dequeue(); Assert.AreEqual(i, a); } }
static void Main(string[] args) { Customer c1 = new Customer() { Id = 101, Name = "Oscar", Gender = "Male" }; Customer c2 = new Customer() { Id = 102, Name = "Alejandara", Gender = "Female" }; Customer c3 = new Customer() { Id = 103, Name = "Juan", Gender = "Male" }; Customer c4 = new Customer() { Id = 104, Name = "Johanna", Gender = "Female" }; Customer c5 = new Customer() { Id = 105, Name = "Ricardo", Gender = "Male" }; // FIFO -> First In First Out Queue<Customer> queueCustomers = new Queue<Customer>(); queueCustomers.Enqueue(c1); queueCustomers.Enqueue(c2); queueCustomers.Enqueue(c3); queueCustomers.Enqueue(c4); queueCustomers.Enqueue(c5); Customer tmpC1 = queueCustomers.Dequeue(); Console.WriteLine(tmpC1.Id + " - " + tmpC1.Name + " Removed!"); Console.WriteLine("Total items in the queue {0}", queueCustomers.Count); Console.ReadKey(); }
public void StandartTest_4() { Queue.Queue queue = new Queue.Queue(); queue.enqueue(1, 6); queue.enqueue(2, 3); queue.enqueue(3, 2); queue.enqueue(4, 5); queue.enqueue(5, 4); queue.enqueue(6, 1); Assert.AreEqual(1, queue.dequeue()); Assert.AreEqual(4, queue.dequeue()); Assert.AreEqual(5, queue.dequeue()); Assert.AreEqual(2, queue.dequeue()); Assert.AreEqual(3, queue.dequeue()); Assert.AreEqual(6, queue.dequeue()); }
static void Main(string[] args) { //вводим путь, указываем папку, о которой хотим узнать информацию; string path = @"D:\2015"; //создаем информацию о папке, которая указана в путе; DirectoryInfo dir = new DirectoryInfo(path); //считает количество файлов в папке; int cnt = dir.GetFiles().Length; //выводит на экран количество файлов, находящиеся в определенной папке; Console.WriteLine(cnt + " files are located in " + dir.FullName); //создаем стек; Queue<DirectoryInfo> items = new Queue<DirectoryInfo>(); //пробегаемся по массиву папок; foreach (DirectoryInfo ndir in dir.GetDirectories()) { //все папки, находящиеся в массиве папки, добавляет в стек; items.Enqueue(ndir); } //задаем условие; while (true) { //пока наш стек не пустой; if (items.Count > 0) { //вытаскиваем из стека элемент самый верхний; DirectoryInfo npopDir = items.Dequeue(); //считаем количество элементов, вытаскиваем и распечатываем их; cnt = npopDir.GetFiles().Length; Console.WriteLine(cnt + " files are located in " + npopDir.FullName); //записываем в массив количество файлов в папке, которые были удалены; DirectoryInfo[] npopDirItems = npopDir.GetDirectories(); //пробегаемся по массиву; foreach (DirectoryInfo npopDirIt in npopDirItems) { //пробегаемся по папкам(файлам) и добавляем их в стек; items.Enqueue(npopDirIt); } } } }
static void Main() { Queue test = new Queue(); test.Enqueue(2); test.Enqueue(3); test.Enqueue(4); test.Dequeue(); test.PrintQueue(); Console.WriteLine("*****************"); Queue<int> test1 = new Queue<int>(); test1.Enqueue(2); test1.Enqueue(3); test1.Enqueue(4); test1.Dequeue(); foreach (int i in test1) { Console.WriteLine(i); } }
static void Main() { Queue Q = new Queue(); object obj; uint i, j; UInt16[] numbers = new UInt16[] { 10, 20, 30 }; for (i = 0; i < numbers.Length; i++) Q.append(numbers[i]); Q.printQueue(); Console.WriteLine("Queue count = {0}", Q.Count); j = Q.Count; for (i = 0; i < j; i++) { obj = Q.serve(); Console.WriteLine("serve Queue = {0}", obj.ToString()); } Console.WriteLine("Queue count = {0}", Q.Count); }
private static void testQueue() { Queue q = new Queue(); string testData = ""; Console.Out.WriteLine("======>Queue Test 1<======"); Console.Out.WriteLine(">>Tests whether or not the addItem and removeItem methods work"); q.addItem("element 1"); testData = q.removeItem(); Console.Out.WriteLine("removeItem() returned: " + testData); Console.Out.Write("Test Passed: "); Console.Out.WriteLine(String.Equals(testData, "element 1") && q.isEmpty()); Console.Out.WriteLine(""); Console.Out.WriteLine("======>Queue Test 2<======"); Console.Out.WriteLine(">>Tests whether or not the getDataAtFront method works"); q.addItem("element 1"); q.addItem("element 2"); q.addItem("element 3"); q.removeItem(); testData = q.itemAtFront(); Console.Out.WriteLine("itemAtFront() returned: " + testData); Console.Out.Write("Test Passed: "); Console.Out.WriteLine(String.Equals(testData, "element 2") && q.isEmpty() == false); Console.Out.WriteLine(""); }
public void StandardExeption_1() { Queue.Queue queue = new Queue.Queue(); queue.dequeue(); }