public virtual void TestClear() { PriorityQueue pq = new IntegerQueue(3); pq.Put((System.Object) 2); pq.Put((System.Object) 3); pq.Put((System.Object) 1); Assert.AreEqual(3, pq.Size()); pq.Clear(); Assert.AreEqual(0, pq.Size()); }
public static void TestPQ(int count, System.Random gen) { PriorityQueue pq = new IntegerQueue(count); int sum = 0, sum2 = 0; for (int i = 0; i < count; i++) { int next = gen.Next(); sum += next; pq.Put((System.Object)next); } // Date end = new Date(); // System.out.print(((float)(end.getTime()-start.getTime()) / count) * 1000); // System.out.println(" microseconds/put"); // start = new Date(); int last = System.Int32.MinValue; for (int i = 0; i < count; i++) { System.Int32 next = (System.Int32)pq.Pop(); Assert.IsTrue(next >= last); last = next; sum2 += last; } Assert.AreEqual(sum, sum2); // end = new Date(); // System.out.print(((float)(end.getTime()-start.getTime()) / count) * 1000); // System.out.println(" microseconds/pop"); }
public static void TestPQ(int count) { PriorityQueue pq = new IntegerQueue(count); System.Random gen = new System.Random(); int sum = 0, sum2 = 0; for (int i = 0; i < count; i++) { int next = gen.Next(); sum += next; pq.Put((System.Object) next); } // Date end = new Date(); // System.out.print(((float)(end.getTime()-start.getTime()) / count) * 1000); // System.out.println(" microseconds/put"); // start = new Date(); int last = System.Int32.MinValue; for (int i = 0; i < count; i++) { System.Int32 next = (System.Int32) pq.Pop(); Assert.IsTrue(next >= last); last = next; sum2 += last; } Assert.AreEqual(sum, sum2); // end = new Date(); // System.out.print(((float)(end.getTime()-start.getTime()) / count) * 1000); // System.out.println(" microseconds/pop"); }