private static int MixCookies() { // get the first two cookies in the list int iMixedCookieSweetness = _heap.Pop(); iMixedCookieSweetness += 2 * _heap.Pop(); return(iMixedCookieSweetness); }
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; } }
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 _)); }
public T Pop() { using (EnterWriteScope()) return(_internalHeap.Pop()); }