Queue/Definition: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 366: | Line 366: | ||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
<lang AutoHotkey>; TEST: push 2, 4 and 6 onto queue named "qu" |
|||
push("qu", 2), push("qu", 4), push("qu", 6) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
ahk forum: [http://www.autohotkey.com/forum/viewtopic.php?t=44657&postdays=0&postorder=asc&start=132 discussion] |
|||
<lang AutoHotkey>push("st",2),push("st",4) ; TEST: push 2 and 4 onto stack named "st" |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
;--------------------------------------------------------------------------- |
|||
push( |
push(queue,x) { ; push x onto queue named "queue" |
||
Local _ ; |
|||
;--------------------------------------------------------------------------- |
|||
_ := %stack%0 := %stack%0="" ? 1 : %stack%0+1 |
|||
global |
|||
⚫ | |||
⚫ | |||
⚫ | |||
Else |
|||
%queue% .= "|" x |
|||
} |
} |
||
⚫ | |||
Local _ ; |
|||
;--------------------------------------------------------------------------- |
|||
_ := %stack%0 |
|||
⚫ | |||
⚫ | |||
;--------------------------------------------------------------------------- |
|||
⚫ | |||
global |
|||
⚫ | |||
StringSplit, Array, %queue%, | |
|||
If (Array0 = 0) { |
|||
⚫ | |||
Return, "" |
|||
} |
|||
If (Array0 = 1) |
|||
%queue% := "" |
|||
Else |
|||
%queue% := SubStr(%queue%, InStr(%queue%, "|") + 1) |
|||
⚫ | |||
} |
|||
;--------------------------------------------------------------------------- |
|||
⚫ | |||
;--------------------------------------------------------------------------- |
|||
global |
|||
⚫ | |||
} |
} |
||
⚫ | |||
⚫ | |||
Global |
|||
⚫ | |||
⚫ | |||
=={{header|C}}== |
=={{header|C}}== |