public TValue ExtractMin() { Debug.Assert(_initialized); if (_size == 0) { return(_heap.ExtractMin()); } TValue sortMin = _keys[_order[_size - 1]]; if (!_heap.Empty) { TValue heapMin = _heap.Minimum(); if (_leq(heapMin, sortMin)) { return(_heap.ExtractMin()); } } do { --_size; } while (_size > 0 && _keys[_order[_size - 1]] == null); return(sortMin); }
public TValue ExtractMin() { if (_size == 0) { return(_heap.ExtractMin()); } TValue val = _keys[_order[_size - 1]]; if (!_heap.Empty) { TValue lhs = _heap.Minimum(); if (_leq(lhs, val)) { return(_heap.ExtractMin()); } } do { _size--; }while (_size > 0 && _keys[_order[_size - 1]] == null); return(val); }