protocol

# `queuep`

Queue protocol.

Availability:
`logtalk_load(queues(loader))`
Author: Paulo Moura
Version: 1:3:0
Date: 2020-12-09
Compilation flags:
`static`
Dependencies:
(none)
Remarks:
(none)
Inherited public predicates:
(none)

## Public predicates

### `empty/1`

True if the queue is empty.

Compilation flags:
`static`
Template:
`empty(Queue)`
Mode and number of proofs:
`empty(@queue)` - `zero_or_one`

### `head/2`

Unifies `Head` with the first element of the queue.

Compilation flags:
`static`
Template:
`head(Queue,Head)`
Mode and number of proofs:
`head(+queue,?term)` - `zero_or_one`

### `join/3`

Adds the new element at the end of the queue.

Compilation flags:
`static`
Template:
`join(Element,Queue,NewQueue)`
Mode and number of proofs:
`join(@term,+queue,-queue)` - `zero_or_one`

### `join_all/3`

Adds the new elements at the end of the queue. The elements are added in the same order that they appear in the list.

Compilation flags:
`static`
Template:
`join_all(List,Queue,NewQueue)`
Mode and number of proofs:
`join_all(+list,+queue,-queue)` - `zero_or_one`

### `jump/3`

Adds the new element at the front of the queue.

Compilation flags:
`static`
Template:
`jump(Element,Queue,NewQueue)`
Mode and number of proofs:
`jump(@term,+queue,-queue)` - `zero_or_one`

### `jump_all/3`

Adds the new elements at the front of the queue. The last element in the list will be at the front of the queue.

Compilation flags:
`static`
Template:
`jump_all(Elements,Queue,NewQueue)`
Mode and number of proofs:
`jump_all(+list,+queue,-queue)` - `zero_or_one`

### `jump_all_block/3`

Adds the new elements as a block at the front of the queue. The first element in the list will be at the front of the queue.

Compilation flags:
`static`
Template:
`jump_all_block(Elements,Queue,NewQueue)`
Mode and number of proofs:
`jump_all_block(+list,+queue,-queue)` - `zero_or_one`

### `append/3`

Appends two queues. The new queue will have the elements of the first queue followed by the elements of the second queue.

Compilation flags:
`static`
Template:
`append(Queue1,Queue2,NewQueue)`
Mode and number of proofs:
`append(+queue,+queue,-queue)` - `one`

### `length/2`

Queue length.

Compilation flags:
`static`
Template:
`length(Queue,Length)`
Mode and number of proofs:
`length(+heap,?integer)` - `zero_or_one`

### `serve/3`

Removes the first element of the queue for service.

Compilation flags:
`static`
Template:
`serve(Queue,Head,NewQueue)`
Mode and number of proofs:
`serve(+queue,?term,-queue)` - `zero_or_one`

### `as_list/2`

Converts a queue to a list.

Compilation flags:
`static`
Template:
`as_list(Queue,List)`
Mode and number of proofs:
`as_list(+queue,-list)` - `one`

### `map/2`

Applies a closure to all elements of a queue.

Compilation flags:
`static`
Template:
`map(Closure,Queue)`
Meta-predicate template:
`map(1,*)`
Mode and number of proofs:
`map(+callable,+queue)` - `zero_or_one`

### `map/3`

Applies a closure to all elements of a queue constructing a new queue.

Compilation flags:
`static`
Template:
`map(Closure,Queue,NewQueue)`
Meta-predicate template:
`map(2,*,*)`
Mode and number of proofs:
`map(+callable,+queue,?queue)` - `zero_or_one`

## Protected predicates

(none)

## Private predicates

(none)

## Operators

(none)

See also

queue