Possible Bug in Binary Heap implementation?

Should a new heap have 2 items? why does a cleared heap have 1?

	public BinaryHeapM ( int numberOfElements ) { 
		binaryHeap = new NodeRun[numberOfElements]; 
		numberOfItems = 2;
	} 
	
	public void Clear () {
		numberOfItems = 1;
	}

The first add will add at 2
binaryHeap[numberOfItems] = node;
But will then compare against its parent at position 1 (in the bubbleup code) which has never been written to…

Hi

That looks like a bug. However it hasn’t affected anything since all scripts call Clear before actually using the queue.

I will fix it til the next release.