public void Remove(PQHandle handle) { Debug.Assert(_initialized); int hCurr = handle._handle; Debug.Assert(hCurr >= 1 && hCurr <= _max && _handles [hCurr]._key != null); int curr = _handles [hCurr]._node; _nodes [curr] = _nodes [_size]; _handles [_nodes [curr]]._node = curr; if (curr <= --_size) { if (curr <= 1 || _leq(_handles [_nodes [curr >> 1]]._key, _handles [_nodes [curr]]._key)) { FloatDown(curr); } else { FloatUp(curr); } } _handles [hCurr]._key = null; _handles [hCurr]._node = _freeList; _freeList = hCurr; }
public void Remove(PQHandle handle) { Debug.Assert(_initialized); int curr = handle._handle; if (curr >= 0) { _heap.Remove(handle); return; } curr = -(curr + 1); Debug.Assert(curr < _max && _keys [curr] != null); _keys [curr] = null; while (_size > 0 && _keys[_order[_size - 1]] == null) { --_size; } }