Priority queue: Difference between revisions
Content added Content deleted
Line 6,977: | Line 6,977: | ||
if size>ubound(q) then redim preserve q(ubound(q)*1.1) |
if size>ubound(q) then redim preserve q(ubound(q)*1.1) |
||
q(size)=x |
q(size)=x |
||
⚫ | |||
sift_up |
sift_up |
||
end sub |
end sub |
||
Line 6,990: | Line 6,989: | ||
h=size |
h=size |
||
p=h\2 |
p=h\2 |
||
⚫ | |||
while out_of_order(q(p),q(h)) |
|||
swap h,p |
swap h,p |
||
h=p |
h=p |
||
p=h\2 |
p=h\2 |
||
if p=0 then exit sub |
|||
wend |
wend |
||
end sub |
|||
end sub |
end sub |
||
Line 7,058: | Line 7,060: | ||
5 Make tea |
5 Make tea |
||
</pre> |
</pre> |
||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
{{libheader|Wren-queue}} |
{{libheader|Wren-queue}} |