Exemplo n.º 1
0
        public void Merge_WithEmpty_CountUnchanged()
        {
            var heap = new PairingHeap <int>();

            heap.Insert(0);
            heap.Merge(new());
            Assert.That(heap.Count(), Is.EqualTo(1));
        }
Exemplo n.º 2
0
        public void Merge_WithNonEmpty_CountChanged()
        {
            var heap  = new PairingHeap <int>();
            var other = new PairingHeap <int>();

            other.Insert(0);
            heap.Merge(other);
            Assert.That(heap.Count(), Is.EqualTo(1));
        }
Exemplo n.º 3
0
        public void Insert_MultipleTimesIntoEmpty_CountIsCorrect(int size)
        {
            var heap = new PairingHeap <int>();

            for (var i = 0; i < size; i++)
            {
                heap.Insert(0);
            }

            Assert.That(heap.Count(), Is.EqualTo(size));
        }
Exemplo n.º 4
0
        public void Remove_MiddleElement_DecreasesCount()
        {
            var heap = new PairingHeap <int>();

            heap.Insert(2);
            var pointer = heap.Insert(1);

            heap.Insert(0);
            heap.Remove(pointer);
            Assert.That(heap.Count(), Is.EqualTo(2));
        }
Exemplo n.º 5
0
        public void Remove_ManyElements_DecreasesCount()
        {
            var heap = new PairingHeap <int>();

            for (var i = 0; i < 15; i++)
            {
                heap.Insert(i);
            }

            var pointer = heap.Insert(5);

            heap.Remove(pointer);

            Assert.That(heap.Count(), Is.EqualTo(15));
        }
Exemplo n.º 6
0
        public void Count_Empty_IsZero()
        {
            var heap = new PairingHeap <int>();

            Assert.That(heap.Count(), Is.Zero);
        }
Exemplo n.º 7
0
        public void Ctor_DefaultComparer_CountIsZero()
        {
            var heap = new PairingHeap <int>(Comparer <int> .Default);

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