public MinHeapKMergeType <T> RemoveMin() { if (this.Count == 0) { throw new IndexOutOfRangeException(); } MinHeapKMergeType <T> min = internalArray[0]; if (this.Count == 1) { --this.Count; return(min); } internalArray[0] = internalArray[LastChildIndex]; // this is for non zero elements just to make sure for debugging not confused internalArray[LastChildIndex] = default; --Count; if (this.Count > 1) { HeapifyIndexDown(0); } return(min); }
private void Swap(MinHeapKMergeType <T>[] array, int aIndex, int bIndex) { MinHeapKMergeType <T> temp = array[aIndex]; array[aIndex] = array[bIndex]; array[bIndex] = temp; }
public void Add(MinHeapKMergeType <T> item) { if (this.Count == this.size) { this.IncreaseHeapSize(); } internalArray[this.Count++] = item; if (this.Count > 1) { HeapifyIndexUp(LastChildIndex); } }