Beispiel #1
0
        public void ConstructorUsingComparator()
        {
            MyReverseComparator cmp = new MyReverseComparator();
            PriorityQueue       q   = new PriorityQueue(SIZE, cmp);

            Assert.AreEqual(cmp, q.Comparator());
            Int32[] ints = new Int32[SIZE];
            for (int i = 0; i < SIZE; ++i)
            {
                ints[i] = i;
            }
            q.AddAll(new ArrayList(ints));
            for (int i = SIZE - 1; i >= 0; --i)
            {
                Assert.AreEqual(ints[i], q.Poll());
            }
            Assert.IsTrue(q.IsEmpty);
        }
		public void ConstructorUsingComparator()
		{
			MyReverseComparator cmp = new MyReverseComparator();
			PriorityQueue q = new PriorityQueue(SIZE, cmp);
			Assert.AreEqual(cmp, q.Comparator());
			Int32[] ints = new Int32[SIZE];
			for (int i = 0; i < SIZE; ++i)
				ints[i] = i;
			q.AddAll(new ArrayList(ints));
			for (int i = SIZE - 1; i >= 0; --i)
				Assert.AreEqual(ints[i], q.Poll());
			Assert.IsTrue( q.IsEmpty );
		}