arsenal.deathrow package

Submodules

arsenal.deathrow.prioritydict module

class arsenal.deathrow.prioritydict.prioritydict(*args, **kwargs)[source]

Bases: dict

Dictionary that can be used as a priority queue.

Keys of the dictionary are items to be put into the queue, and values are their respective priorities. All dictionary methods work as expected. The advantage over a standard heapq-based priority queue is that priorities of items can be efficiently updated (amortized O(1)) using code as ‘thedict[item] = new_priority.’

The ‘smallest’ method can be used to return the object with lowest priority, and ‘pop_smallest’ also removes it.

The ‘sorted_iter’ method provides a destructive sorted iterator.

This implemented is based on:

Matteo Dell’Amico’s implementation http://code.activestate.com/recipes/522995-priority-dict-a-priority-queue-with-updatable-prio/

which is based on David Eppstein’s implementation http://code.activestate.com/recipes/117228/
pop_smallest(value=False)[source]

Return the item with the lowest priority and remove it.

Raises IndexError if the object is empty.

setdefault = None
update = None

Module contents