Пример #1
0
        public void ExtractMinimum_ManyElements_CanSortSequence(params int[] values)
        {
            var heap = new BinaryHeap <int>();

            foreach (var value in values)
            {
                heap.Insert(value);
            }

            var sorted = new List <int>();

            while (heap.Count > 0)
            {
                sorted.Add(heap.ExtractMinimum());
            }

            Assert.That(sorted, Is.EqualTo(values.OrderBy(x => x).ToList()));
        }
Пример #2
0
        public void ExtractMinimum_Empty_Throws()
        {
            var heap = new BinaryHeap <int>();

            Assert.That(() => heap.ExtractMinimum(), Throws.InvalidOperationException);
        }
Пример #3
0
        public void Count_Empty_IsZero()
        {
            var heap = new BinaryHeap <int>();

            Assert.That(heap.Count, Is.Zero);
        }
Пример #4
0
        public void Ctor_Capacity_CountIsZero()
        {
            var heap = new BinaryHeap <int>(42, Comparer <int> .Default);

            Assert.That(heap.Count, Is.Zero);
        }