Scheme 48 Manual -- Queues

Scheme 48 Manual | Contents | In Chapter: Libraries
Previous: Cells | Next: Arrays

## Queues

These are ordinary first-in, first-out queues. The procedures are in structure `queues`.

- `(make-queue) -> queue`
- `(queue? value) -> boolean`
- `(queue-empty? queue) -> boolean`
- `(enqueue! queue value)`
- `(dequeue! queue) -> value`

`Make-queue` creates an empty queue, `queue?` is a predicate for identifying queues, `queue-empty?` tells you if a queue is empty, `enqueue!` and `dequeue!` add and remove values.

- `(queue-length queue) -> integer`
- `(queue->list queue) -> values`
- `(list->queue values) -> queue`
- `(delete-from-queue! queue value) -> boolean`

`Queue-length` returns the number of values in queue. `Queue->list` returns the values in queue as a list, in the order in which the values were added. `List->queue` returns a queue containing values, preserving their order. `Delete-from-queue` removes the first instance of value from `queue`, using `eq?` for comparisons. `Delete-from-queue` returns `#t` if value is found and `#f` if it is not.

Previous: Cells | Next: Arrays