openplans/OpenTripPlanner — Issue #590: IntBinHeap issue
Author: karussell
Created: 2012-01-24 23:48:51+00:00
State: open

Not sure if this class is used but I tried it and it has a mistake in there. Uncovered hardly via infinte loop in rekey:

IntBinHeap binHeap = new IntBinHeap(100);
binHeap.insert(0, 123);
assertEquals(123, binHeap.peekMinKey(), 1e-4);
assertEquals(1, binHeap.size());

binHeap.rekey(0, 12);
assertEquals(12, binHeap.peekMinKey(), 1e-4);
assertEquals(1, binHeap.size());

Solve this in the constructor via:

elem[0] = Integer.MIN_VALUE;

BTW: would be nice if this class supports something like

public (static) int notAnElement = Integer.MIN_VALUE;

like the trove collection classes ...