QueueWorld#
QueueWorld visualizes a FIFO queue as a row of boxes growing left-to-right.
The front box (next to be dequeued) is highlighted in red;
the back box (most recently enqueued) in purple.
Operations#
Method |
Description |
|---|---|
|
Add a value to the back. Raises |
|
Remove and return the front value. Raises |
|
Return the front value without removing it. Raises |
|
Return the back value without removing it. Raises |
|
Return all current elements, front-to-back order. |
|
Return |
|
Return |
|
Remove all elements. |
|
Number of elements currently in the queue (property). |
Constructor parameters#
Parameter |
Default |
Description |
|---|---|---|
|
|
Maximum number of elements. |
|
|
Width of each element box in pixels. |
|
|
Height of each element box in pixels. |
|
|
Margin around the queue in pixels. |
|
light grey |
Background fill color. |
Example#
from miniworlds_data import QueueWorld
world = QueueWorld(capacity=5)
world.enqueue(10)
world.enqueue(20)
world.enqueue(30)
print(world.front()) # 10
print(world.dequeue()) # 10
world.run()