libutilitaspy.data_structures.priority_queues

Implements priority queues using heaps.

class libutilitaspy.data_structures.priority_queues.PriorityQueue(data=None, ascending=False)[source]

A priority queue is a queue of items such that its elements are extracted in order of their priority (see http://en.wikipedia.org/wiki/Priority_queue).

The priority of the items determines how they are compared, thus this class assumes that if two objects a and b are to be put in a queue with ascending order, a < b if and only if a’s priority is higher than b’s. Dually, if they are put in a queue with descending order, a > b if and only if a’s priority is higher than b’s.

The constructor creates a new queue from a given sequence.

Parameters:
  • data (MutableSequence) – an initial sequence of comparable objects.
  • ascending (bool) – True if the items are sorted in ascending order, False for descending order.
Todo :

map data items to PQE

Previous topic

libutilitaspy.data_structures.heaps

Next topic

libutilitaspy.data_structures.partitions

This Page