Пример #1
0
        public void FibonacciHeapRemovePeekTest()
        {
            FibonacciHeap <Int32, String> heap = new FibonacciHeap <Int32, String>();

            for (Int32 index = 0; index < this.values.Length; index++)
            {
                heap.Insert(this.values[index].Key, this.values[index].Value);

                heap.Peek.ShouldBe(this.values.Take(index + 1).Select(item => item.Key).Min().ToString());
            }

            while (heap.Count > 0)
            {
                String peek = heap.Peek;
                heap.RemovePeek().ShouldBe(peek);
                this.values.Select(item => item.Value).Contains(peek).ShouldBeTrue();
            }

            // exceptions

            Should.Throw <InvalidOperationException>(() => new FibonacciHeap <String, String>().RemovePeek());
        }