Just testing source code formatting:
private void DownHeap(int index)
{
T item = _heap[index];
int count = _heap.Count;
int firstChild = (index << 1) + 1;
int secondChild = firstChild + 1;
int smallestChild = (secondChild < count && Comparer.Compare(_heap[secondChild], _heap[firstChild]) < 0) ? secondChild : firstChild;
while( smallestChild < count && Comparer.Compare(_heap[smallestChild], item) < 0 )
{
_heap[index] = _heap[smallestChild];
index = smallestChild;
firstChild = (index << 1) + 1;
secondChild = firstChild + 1;
smallestChild = (secondChild < count && Comparer.Compare(_heap[secondChild], _heap[firstChild]) < 0) ? secondChild : firstChild;
}
_heap[index] = item;
}
EDIT: Ok, that works, only copy/pasting directly from VS messes up the spacing. And there's still a text overflow issue with long lines of source code.