Beispiel #1
0
        private static int MixCookies()
        {
            // get the first two cookies in the list
            int iMixedCookieSweetness = _heap.Pop();

            iMixedCookieSweetness += 2 * _heap.Pop();
            return(iMixedCookieSweetness);
        }
Beispiel #2
0
        void AssertMaxToMin(IHeap <int> maxHeap)
        {
            int currentValue = maxHeap.Pop();

            for (int i = 1; i < maxHeap.Count; i++)
            {
                int nextValue = maxHeap.Pop();
                Assert.IsTrue(currentValue >= nextValue);
                currentValue = nextValue;
            }
        }
Beispiel #3
0
        void AssertMinToMax(IHeap <int> minHeap)
        {
            int currentValue = minHeap.Pop();

            for (int i = 1; i < minHeap.Count; i++)
            {
                int nextValue = minHeap.Pop();
                Assert.IsTrue(currentValue <= nextValue);
                currentValue = nextValue;
            }
        }
        public void Pop_N_TryPop_Behaves_For_Empty_Heap(int capacity)
        {
            IHeap <int> instance = Substitute.ForPartsOf <AbstractBinaryHeap <int> >(capacity);

            Assert.Throws <IndexOutOfRangeException>(() => instance.Pop());
            Assert.False(instance.TryPop(out _));
        }
Beispiel #5
0
 public T Pop()
 {
     using (EnterWriteScope()) return(_internalHeap.Pop());
 }