Priority queue: Difference between revisions
Content added Content deleted
Line 4,681: | Line 4,681: | ||
<syntaxhighlight lang="m2000 interpreter"> |
<syntaxhighlight lang="m2000 interpreter"> |
||
// using pointers to objects |
|||
global countmany=0& |
global countmany=0& |
||
class obj { |
class obj { |
||
Line 4,722: | Line 4,721: | ||
Header() |
Header() |
||
while not @isEmpty(b) |
while not @isEmpty(b) |
||
Print @Pop(b)=>tostring$ |
//Print @Pop(b)=>tostring$ |
||
checkme(@Pop(b)) |
|||
end while |
end while |
||
ObjectCount() |
ObjectCount() |
||
Line 4,741: | Line 4,741: | ||
push n |
push n |
||
local t=2, b=len(a) |
local t=2, b=len(a) |
||
local m=b |
|||
while t<=b |
|||
t1=m |
t1=m |
||
m=(b+t) div 2 |
m=(b+t) div 2 |
||
Line 4,763: | Line 4,763: | ||
end function |
end function |
||
Function Pop(a) |
Function Pop(a) |
||
// Group make a copy |
// Group make a copy |
||
// also drop the pointer from the top of stack |
|||
stack a {=Group} |
stack a {=Group} |
||
end function |
end function |
||
sub checkme(a as *obj) |
|||
Print a=>tostring$ |
|||
end sub |
|||
} |
} |
||
PriorityQueueForGroups |
PriorityQueueForGroups |