//inverts the order of the items in a ds_queue
//argument0=queue id
//argument1=returnqueue. If this is set to TRUE, it returns a new queue, if it is set to false, it will just edit the existing queue.
var queue, stack, val, copy ;
queue=ds_queue_create()
stack=ds_stack_create()
copy=ds_queue_create()
ds_queue_copy(copy,argument0)
do
{
val=ds_queue_dequeue(copy)
ds_stack_push(stack,val)
}
until (ds_queue_size(copy)=0)
if (argument1=false) ds_queue_clear(argument0)
do
{
val=ds_stack_pop(stack)
if (argument1=true)
ds_queue_enqueue(queue,val)
else
ds_queue_enqueue(argument0)
}
until (ds_stack_size(stack)=0)
if (argument1=true) return(queue) else return(argument0)
Categories: Data processing
There are no comments to display.
You must be signed in to post comments.