Sample Queue¶
Class that creates a queue which contains the samples that are created in the system.
-
class mundo.api.sample_queue.SampleQueue(
data: Dict[str, Any]
)¶ This class creates and modifies a queue containing samples. The queue functions by providing an order as to how the samples should be processed.
The GUI uses this class to add, remove, and change the queue. The system will automatically remove processed samples from the queue.
Note that the sample platform coordinate begin at (0,0) in all aspects but the presented labels in the GUI values. Meaning label texts would be defined as (row+1, column+1), where row and column begin from 0.
-
__init__(
data: Dict[str, Any]
) None ¶ Creates an empty queue.
- Parameters
data – The saved serialized data, if any
- property size: int¶
Returns the current size of the queue.
- Returns
The number of items in the queue
- property items: List[Tuple[int, int]]¶
Retrieve all the items of the queue.
- Returns
A list of the items in the queue
-
exists(
position: Tuple[int, int]
) bool ¶ Check whether a sample is in the queue.
- Param
The position (row, column) of the sample
-
enqueue(
position: Tuple[int, int]
) None ¶ Add an element to the back of the queue
- Parameters
position – The position (row, column) of the sample
-
enqueue_first(
position: Tuple[int, int]
)¶ Add an element to the front of the queue
- Parameters
position – The position (row, column) of the sample
- dequeue() Optional[Tuple[int, int]] ¶
Get and remove first element in queue, the first element is the rear
- Returns
The sample at the front of the queue. None otherwise
-
dequeue_position(
position: Tuple[int, int],
queue_index: Optional[int] = None
) None ¶ Dequeues a sample, given its (row, column) position. If a sample is queued multiple times, all entries from that sample are dequeued.
- Parameters
position – The position (row, column) of the sample
queue_index – The index of the sample in the queue. Used when only one sample
is to be dequeued.
-
remove(
idx: int
) None ¶ Remove a specified sample in the queue.
- Parameters
idx – The index of the sample in the queue
-
up(
idx: int
) None ¶ Move sample forward in the queue by one.
- Parameters
idx – the index of the sample in the queue
-
down(
idx: int
) None ¶ Move sample down in the queue.
- Parameters
idx – the index of the sample to move down in the queue.
- clear() None ¶
Set the queue to a empty list
- serialize() Dict[str, Any] ¶
Serializes the sample queue into a JSON encodable dictionary containing the queued samples.
- Returns
A JSON encodable dictionary containing the queue data
-
__init__(