Public Member Functions | |
def | __init__ |
def | __iter__ |
def | __setitem__ |
def | setdefault |
def | smallest |
Private Attributes | |
__heap |
Definition at line 7 of file priodict.py.
def priodict.priorityDictionary.__init__ | ( | self | ) |
Initialize priorityDictionary by creating binary heap of pairs (value,key). Note that changing or removing a dict entry will not remove the old pair from the heap until it is found by smallest() or until the heap is rebuilt.
Definition at line 8 of file priodict.py.
def priodict.priorityDictionary.__iter__ | ( | self | ) |
Create destructive sorted iterator of priorityDictionary.
Definition at line 36 of file priodict.py.
def priodict.priorityDictionary.__setitem__ | ( | self, | |
key, | |||
val | |||
) |
Change value stored in dictionary and add corresponding pair to heap. Rebuilds the heap if the number of deleted items grows too large, to avoid memory leakage.
Definition at line 45 of file priodict.py.
def priodict.priorityDictionary.setdefault | ( | self, | |
key, | |||
val | |||
) |
Reimplement setdefault to call our customized __setitem__.
Definition at line 64 of file priodict.py.
def priodict.priorityDictionary.smallest | ( | self | ) |
Find smallest item after removing deleted items from heap.
Definition at line 16 of file priodict.py.
priodict.priorityDictionary::__heap [private] |
Definition at line 11 of file priodict.py.