Queue¶
- class guppylang.std.collections.Queue[source]¶
A first-in-first-out (FIFO) growable collection of values.
To ensure static allocation, the maximum queue size must be specified in advance and is tracked in the type. For example, Queue[int, 10] is a queue that can hold at most 10 integers.
Implemented as a circular buffer, giving O(1) push and pop.
Use empty_queue to construct a new queue.
- discard_empty() None[source]¶
Discards a queue of potentially non-droppable elements assuming that the queue is empty.
Panics if the queue is not empty.
- peek() TCopyable[source]¶
Returns a copy of the top element of the queue without removing it.
Panics if the queue is empty.
Note that this operation is only allowed if the queue elements are copyable.