http://zorba.io/modules/queue

View as XML or JSON.

Implementation of queue for items, using dynamic collections.

Entries in the queue must be structured items - that is, either JSON Objects or Arrays, or XML Nodes.

Function Summary

back ($name as xs:QName) as structured-item()?

Return the last item in the queue (the last added), without removing it.

copy ($destName as xs:QName, $sourceName as xs:QName) as empty-sequence()

Copy all items from source queue to a destination queue.

create ($name as xs:QName) as empty-sequence()

Create a queue with the name given.

empty ($name as xs:QName) as xs:boolean

Checks if a queue exists and is empty.

front ($name as xs:QName) as structured-item()?

Return the first item in the queue (the first added), without removing it.

pop ($name as xs:QName) as structured-item()?

Return the first item in the queue, and remove it.

push ($name as xs:QName, $value as structured-item()) as empty-sequence()

Add a new item to the queue; the queue will contain a copy of the given item.

size ($name as xs:QName) as xs:integer

Count of items in the queue.

Functions

back#1

declare  function queue:back($name as xs:QName) as structured-item()?
Return the last item in the queue (the last added), without removing it.

Parameters

name as xs:QName
name of the queue.

Returns

structured-item()?
the last item, or empty sequence if queue is empty.

copy#2

declare  %ann:sequential function queue:copy($destName as xs:QName, $sourceName as xs:QName) as empty-sequence()
Copy all items from source queue to a destination queue.

If destination queue does not exist, it is created first.

If destination queue is not empty, the items are appended last.

Parameters

destName as xs:QName
name of the destination queue.
sourceName as xs:QName
name of the source queue.

Returns

empty-sequence()
an empty sequence.

create#1

declare  %ann:sequential function queue:create($name as xs:QName) as empty-sequence()
Create a queue with the name given. If a queue with the given name already exists, an error is raised.

Parameters

name as xs:QName
name of the new queue.

Returns

empty-sequence()
an empty sequence.

empty#1

declare  function queue:empty($name as xs:QName) as xs:boolean
Checks if a queue exists and is empty.

Parameters

name as xs:QName
name of the queue.

Returns

xs:boolean
true is the queue is empty, false if it is not empty.

front#1

declare  function queue:front($name as xs:QName) as structured-item()?
Return the first item in the queue (the first added), without removing it.

Parameters

name as xs:QName
name of the queue.

Returns

structured-item()?
the first item, or empty sequence if queue is empty.

pop#1

declare  %ann:sequential function queue:pop($name as xs:QName) as structured-item()?
Return the first item in the queue, and remove it.

Parameters

name as xs:QName
name of the queue.

Returns

structured-item()?
the first item, or empty sequence if queue is empty.

push#2

declare  %ann:sequential function queue:push($name as xs:QName, $value as structured-item()) as empty-sequence()
Add a new item to the queue; the queue will contain a copy of the given item.

Parameters

name as xs:QName
name of the queue.
value as structured-item()
the item to be added.

Returns

empty-sequence()
()

size#1

declare  function queue:size($name as xs:QName) as xs:integer
Count of items in the queue.

Parameters

name as xs:QName
name of the queue.

Returns

xs:integer
the count of items.