Fri 05 Feb 2016 09:40:34 AM UTC, original submission:
example, with two SimulationMembers: ui and core
heap:
0: <10, ui>
1: <10, core>
heap->size=2
remove minimum and insert:
k=40 v=ui
execution:
i = 1
first iteration:
left = i*2 = 2
right = i*2+1 = 3
smallest = i = 1
if(1 < 2 && 10 < 40) // true
smallest = left = 2
if(2 < 2 && ...) // false
if(smallest == i) // false
k_temp, v_temp = heap[smallest-1] = heap[1] = <10, core>
heap[1] = <40, ui>
k, v = k_temp, v_temp = <10, core>
i = smallest = 2
second iteration:
left = i*2 = 4
right = i*2+1 = 5
smallest = 2
if(3 < 2 && ...) // false
if(4 < 2 && ...) // false
if(smallest == i) // true
heap[smallest-1] = heap[1] = k,v = <10, core>
return
heap:
0: <10, ui>
1: <10, core>
meaning that core->Step will not be called again until ui has finished
a patch that fixes this bug (among other things) is
http://sgerwk.altervista.org/simulavrscript/simulavr-1.0.0.patch
|