Beispiel #1
0
	public void IntervalHeap()
	{
		IntervalHeap<int> heap = new IntervalHeap<int>(Comparer<int>.Default);

		for (int i = 0; i < kHeapTestSize; ++i)
			heap.Insert(Random.Range(int.MinValue + 1, int.MaxValue));

		Assert.IsTrue(heap.Validate());

		int least = int.MinValue;
		int greatest = int.MaxValue;
		while (heap.Count > 0)
		{
			int next = heap.ExtractMin();
			Assert.IsTrue(next >= least);
			least = next;

			next = heap.ExtractMax();
			Assert.IsTrue(next <= greatest);
			greatest = next;
		}
	}