mlpy.auxiliary.datastructs.FIFOQueue

class mlpy.auxiliary.datastructs.FIFOQueue[source]

Bases: mlpy.auxiliary.datastructs.Queue

The first-in-first-out (FIFO) queue.

In a FIFO queue the first element added to the queue is the first element to be removed.

See also

PriorityQueue

Examples

>>> q = FIFOQueue()
>>> q.push(5)
>>> q.extend([1, 3, 7])
>>> print q
[5, 1, 3, 7]

Retrieving an element:

>>> q.pop()
5

Removing an element:

>>> q.remove(3)
>>> print q
[1, 7]

Get the element in the queue identical to the given item:

>>> q.get(7)
7

Check if the queue is empty:

>>> q.empty()
False

Loop over the elements in the queue:

>>> for x in q:
>>>     print x
1
7

Check if an element is in the queue:

>>> if 7 in q:
>>>     print "yes"
yes

Methods

empty() Check if the queue is empty.
extend(items) Append a list of elements at the end of the queue.
get(item) Return the element in the queue identical to item.
pop() Return the element at the front of the queue.
push(item) Push an element to the end of the queue.
remove(item) Remove an element from the queue.