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() { Debug.Assert(_initialized); switch (_size) { case 0: return(_heap.ExtractMin()); } TValue sortMin = _keys[_order[_size - 1]]; switch (_heap.Empty) { case false: { TValue heapMin = _heap.Minimum(); if (_leq(heapMin, sortMin)) { return(_heap.ExtractMin()); } break; } } do { --_size; } while (_size > 0 && _keys[_order[_size - 1]] == null); return(sortMin); }