datasim.Queue

class datasim.Queue(world, id: str, capacity: int = 0, gather: bool = True, data_id: str = '', sample_frequency: int = 1, plot_options: ~datasim.types.PlotOptions = <datasim.types.PlotOptions object>)

A queue for entities to wait for resource availability.

__init__(world, id: str, capacity: int = 0, gather: bool = True, data_id: str = '', sample_frequency: int = 1, plot_options: ~datasim.types.PlotOptions = <datasim.types.PlotOptions object>)

Create a waiting queue for entities.

Parameters:
  • world – The world to add this Queue to.

  • id (str) – Identifier / name of the queue.

  • capacity (int) – Maximum queue length. Defaults to 0 for no maximum.

  • gather (PlotType or False, optional) – Whether to automatically gather data for the output for this resource, and which type of plot if so. Defaults to PlotType.none to only save.

  • data_id (str, optional) – id for the data source if gather is True. Defaults to empty string which sets data_id to the value of this Queue’s id.

  • sample_frequency (int, optional) – Whether to add a data point every frequency ticks. If set to 0, adds a data point only when the quantity changes. Defaults to 1.

  • plot_options (Optional[PlotOptions], optional) – Options for a plot. Defaults to default PlotOptions.

Methods

__init__(world, id[, capacity, gather, ...])

Create a waiting queue for entities.

add_output([data_id, frequency, plot_options])

Create an output source for this Queue.

dequeue()

Remove the entity from the front of the queue and returns it.

enqueue(entity[, amount])

Put an entity at the end of the queue.

peek()

Return the entity at the front of the queue without removing it.

peek_with_amount()

Return the entity at the front of the queue without removing it.

queue_prioritized(entity, sort_function)

Pushes an entity to a sorted place in the list

Attributes

full

Check the queue is full.

world

id

queue

capacity

changed_tick