Queues¶
- class rate_control.queues.Queue[source]¶
Bases:
ABC
,Generic
[_T
]Abstract class for representing a queue.
- abstract __repr__() str [source]¶
String representation of the queue.
The elements appear in the order they will be popped.
- abstract add(element: _T) None [source]¶
Add the given element to the queue.
- Parameters:
element (
TypeVar
(_T
)) – The element in question.
- abstract head() _T [source]¶
- Returns:
The element at the head of the queue.
- Raises:
Empty – The queue is empty.
- class rate_control.queues.FifoQueue[source]¶
Bases:
Queue
[_T
]“First In, First Out” queue.
- __init__(*elements: _T, **kwargs: Any) None [source]¶
- Parameters:
elements (
TypeVar
(_T
)) – The elements to initialize the queue with.
- add(element: _T) None [source]¶
Add the given element to the queue.
- Parameters:
element (
TypeVar
(_T
)) – The element in question.
- head() _T [source]¶
- Returns:
The element at the head of the queue.
- Raises:
Empty – The queue is empty.
- class rate_control.queues.LifoQueue[source]¶
Bases:
Queue
[_T
]“Last In, First Out” queue.
- __init__(*elements: _T, **kwargs: Any) None [source]¶
- Parameters:
elements (
TypeVar
(_T
)) – The elements to initialize the queue with.
- add(element: _T) None [source]¶
Add the given element to the queue.
- Parameters:
element (
TypeVar
(_T
)) – The element in question.
- head() _T [source]¶
- Returns:
The element at the head of the queue.
- Raises:
Empty – The queue is empty.
- class rate_control.queues.PriorityQueue[source]¶
Bases:
Queue
[_T
]Queue where the lowest valued elements are retrieved first.
Warning
Equally valued elements are not guaranteed to be retrieved in the order they arrived.
- __init__(*elements: _T, **kwargs: Any) None [source]¶
- Parameters:
elements (
TypeVar
(_T
, bound=Comparable
)) – The elements to initialize the queue with.
- add(element: _T) None [source]¶
Add the given element to the queue.
- Parameters:
element (
TypeVar
(_T
, bound=Comparable
)) – The element in question.
- head() _T [source]¶
- Returns:
The element at the head of the queue.
- Raises:
Empty – The queue is empty.
- pop() _T [source]¶
Remove the element at the head of the queue, and return it.
- Returns:
The element at the head of the queue.
- Raises:
Empty – The queue is empty.
- remove(element: _T) None [source]¶
Delete the given element from the queue.
- Parameters:
element (
TypeVar
(_T
, bound=Comparable
)) – The element in question.- Raises:
ValueError – The element is not present in the queue.