public virtual void TestInsertWithOverflow() { // Tests that InsertWithOverflow discards the correct value, // and the resulting PQ preserves its structure int size = 4; PriorityQueue <int?> pq = new IntegerQueue(size); int?i1 = 2; int?i2 = 3; int?i3 = 1; int?i4 = 5; int?i5 = 7; int?i6 = 1; Assert.IsNull(pq.InsertWithOverflow(i1)); Assert.IsNull(pq.InsertWithOverflow(i2)); Assert.IsNull(pq.InsertWithOverflow(i3)); Assert.IsNull(pq.InsertWithOverflow(i4)); Assert.IsTrue(pq.InsertWithOverflow(i5) == i3); // i3 should have been dropped Assert.IsTrue(pq.InsertWithOverflow(i6) == i6); // i6 should not have been inserted Assert.AreEqual(size, pq.Count); Assert.AreEqual((int?)2, pq.Top); // LUCENENET SPECIFIC pq.Pop(); Assert.AreEqual((int?)3, pq.Top); pq.Pop(); Assert.AreEqual((int?)5, pq.Top); pq.Pop(); Assert.AreEqual((int?)7, pq.Top); }
public void TestFixedSize() { PriorityQueue <int?> pq = new IntegerQueue(3); pq.InsertWithOverflow(2); pq.InsertWithOverflow(3); pq.InsertWithOverflow(1); pq.InsertWithOverflow(5); pq.InsertWithOverflow(7); pq.InsertWithOverflow(1); assertEquals(3, pq.Count); assertEquals((int?)3, pq.Top); }
public virtual void TestFixedSize() { PriorityQueue <int?> pq = new IntegerQueue(3); pq.InsertWithOverflow(2); pq.InsertWithOverflow(3); pq.InsertWithOverflow(1); pq.InsertWithOverflow(5); pq.InsertWithOverflow(7); pq.InsertWithOverflow(1); Assert.AreEqual(3, pq.Size()); Assert.AreEqual(3, pq.Top()); }
public virtual void TestInsertWithOverflowDoesNotOverflow() { // Tests that InsertWithOverflow does not cause overflow PriorityQueue <int?> pq = new IntegerQueue(3); pq.InsertWithOverflow(2); pq.InsertWithOverflow(3); pq.InsertWithOverflow(1); pq.InsertWithOverflow(5); pq.InsertWithOverflow(7); pq.InsertWithOverflow(1); Assert.AreEqual(3, pq.Count); Assert.AreEqual((int?)3, pq.Top); }
public virtual void TestInsertWithOverflow() { int size = 4; PriorityQueue <int?> pq = new IntegerQueue(size); int?i1 = 2; int?i2 = 3; int?i3 = 1; int?i4 = 5; int?i5 = 7; int?i6 = 1; Assert.IsNull(pq.InsertWithOverflow(i1)); Assert.IsNull(pq.InsertWithOverflow(i2)); Assert.IsNull(pq.InsertWithOverflow(i3)); Assert.IsNull(pq.InsertWithOverflow(i4)); Assert.IsTrue(pq.InsertWithOverflow(i5) == i3); // i3 should have been dropped Assert.IsTrue(pq.InsertWithOverflow(i6) == i6); // i6 should not have been inserted Assert.AreEqual(size, pq.Size()); Assert.AreEqual((int?)2, pq.Top()); }
public virtual void TestInsertWithOverflow() { int size = 4; PriorityQueue pq = new IntegerQueue(size); System.Int32 i1 = 2; System.Int32 i2 = 3; System.Int32 i3 = 1; System.Int32 i4 = 5; System.Int32 i5 = 7; System.Int32 i6 = 1; Assert.IsNull(pq.InsertWithOverflow(i1)); Assert.IsNull(pq.InsertWithOverflow(i2)); Assert.IsNull(pq.InsertWithOverflow(i3)); Assert.IsNull(pq.InsertWithOverflow(i4)); Assert.IsTrue((int)pq.InsertWithOverflow(i5) == i3); // i3 should have been dropped Assert.IsTrue((int)pq.InsertWithOverflow(i6) == i6); // i6 should not have been inserted Assert.AreEqual(size, pq.Size()); Assert.AreEqual(2, ((System.Int32)pq.Top())); }
public virtual void TestInsertWithOverflow() { int size = 4; PriorityQueue pq = new IntegerQueue(size); System.Int32 i1 = 2; System.Int32 i2 = 3; System.Int32 i3 = 1; System.Int32 i4 = 5; System.Int32 i5 = 7; System.Int32 i6 = 1; Assert.IsNull(pq.InsertWithOverflow((System.Object) i1)); Assert.IsNull(pq.InsertWithOverflow((System.Object) i2)); Assert.IsNull(pq.InsertWithOverflow((System.Object) i3)); Assert.IsNull(pq.InsertWithOverflow((System.Object) i4)); Assert.IsTrue((int)pq.InsertWithOverflow((System.Object)i5) == i3); // i3 should have been dropped Assert.IsTrue((int)pq.InsertWithOverflow((System.Object)i6) == i6); // i6 should not have been inserted Assert.AreEqual(size, pq.Size()); Assert.AreEqual(2, ((System.Int32) pq.Top())); }