Priority queue: Difference between revisions

Content deleted Content added
m →‎version 1: added/changed comments, indentations, and whitespace.
Line 193: Line 193:
[1,"Solve RC tasks"]]
[1,"Solve RC tasks"]]
Type: List(OrderedKeyEntry(Integer,String))</pre>
Type: List(OrderedKeyEntry(Integer,String))</pre>
=={{header|Batch File}}==
Batch has only a data structure, the environment that incidentally sorts itself automatically by key. The environment has a limit of 64K
<lang Batch File>
@echo off
setlocal enabledelayedexpansion

call :push 10 "item ten"
call :push 2 "item two"
call :push 100 "item one hundred"
call :push 5 "item five"

call :pop & echo !order! !item!
call :pop & echo !order! !item!
call :pop & echo !order! !item!
call :pop & echo !order! !item!
call :pop & echo !order! !item!

goto:eof


:push
set temp=000%1
set queu%temp:~-3%=%2
goto:eof

:pop
set queu >nul 2>nul
if %errorlevel% equ 1 (set order=-1&set item=no more items & goto:eof)
for /f "tokens=1,2 delims==" %%a in ('set queu') do set %%a=& set order=%%a& set item=%%~b& goto:next
:next
set order= %order:~-3%
goto:eof</lang>
{{out}}
<pre>
002 item two
005 item five
010 item ten
100 item one hundred
-1 no more items
</pre>


=={{header|C}}==
=={{header|C}}==