public PQHandle Insert(TValue value) { if (_initialized) { return(_heap.Insert(value)); } int size = _size; if (++_size >= _max) { _max <<= 1; Array.Resize(ref _keys, _max); } _keys[size] = value; PQHandle result = default(PQHandle); result._handle = -(size + 1); return(result); }
public PQHandle Insert(TValue value) { if (_initialized) { return(_heap.Insert(value)); } int curr = _size; if (++_size >= _max) { _max <<= 1; Array.Resize(ref _keys, _max); } _keys[curr] = value; return(new PQHandle { _handle = -(curr + 1) }); }