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; } }