static void Main(string[] args) { Queuel <int> ql = new Queuel <int>(); var time = System.Diagnostics.Stopwatch.StartNew(); for (int i = 0; i < 100000; i++) { ql.Enqueue(i); } ql.Contains(1); ql.Peek(); for (int i = 0; i < 100000; i++) { ql.Dequeue(); } time.Stop(); var res = time.Elapsed; string eltime = String.Format("{0:00}:{1:00}:{2:00}.{3:000}", res.Hours, res.Minutes, res.Seconds, res.Milliseconds); Console.WriteLine("Lab queue - {0}", eltime); Queue <int> qd = new Queue <int>(); time = System.Diagnostics.Stopwatch.StartNew(); for (int i = 0; i < 100000; i++) { qd.Enqueue(i); } qd.Contains(1); qd.Peek(); for (int i = 0; i < 100000; i++) { qd.Dequeue(); } time.Stop(); res = time.Elapsed; eltime = String.Format("{0:00}:{1:00}:{2:00}.{3:000}", res.Hours, res.Minutes, res.Seconds, res.Milliseconds); Console.WriteLine("Default queue - {0}", eltime); Console.ReadKey(); }
public void ItemsDNtExsistsAfterRemoving() { var q = new Queuel <int>(); for (int i = 0; i < 20; i++) { q.Enqueue(i); } for (int i = 0; i < 20; i++) { int temp = q.Dequeue(); Assert.AreEqual(i, temp); Assert.AreEqual(20 - 1 - i, q.Count); Assert.AreEqual(false, q.Contains(temp)); } }
public void CountInDecreasingTests() { var q = new Queuel <int>(); for (int i = 0; i < 100; i++) { q.Enqueue(i); } Assert.AreEqual(100, q.Count); q.Peek(); Assert.AreEqual(100, q.Count); for (int i = 0; i < 50; i++) { q.Dequeue(); } Assert.AreEqual(50, q.Count); }
public void ContainsIsCorrect() { var q = new Queuel <int>(); for (int i = 0; i < 100; i++) { q.Enqueue(i); } Assert.AreEqual(false, q.Contains(-1)); Assert.AreEqual(true, q.Contains(50)); q.Enqueue(150); Assert.AreEqual(true, q.Contains(150)); q.Dequeue(); Assert.AreEqual(false, q.Contains(0)); q.Peek(); Assert.AreEqual(true, q.Contains(1)); }
public void CorrectOrder() { var q = new Queuel <int>(); int[] a = new int[100]; Random r = new Random(); for (int i = 0; i < a.Length; i++) { a[i] = r.Next(0, 1000); } foreach (var t in a) { q.Enqueue(t); } for (int i = 0; i < a.Length; i++) { int temp = q.Dequeue(); Assert.AreEqual(a[i], temp); } }