"""
A pseudo-heap implemented using a dictionary.

Operations:  
- __len__
- insert
- pop / pop_min
- peek / find_min
- decrease_key

I use this until I find the time to implement a Fibonacci heap.

Author:  
  Christos Nitsas  
  (nitsas)  
  (chrisnitsas)

Language:
  Python 3(.4)

Date:
  August, 2014
"""


__all__ = ["DictHeap"]


class DictHeap:
    """
    A pseudo-heap implemented using a dictionary.
    
    I use this until I find the time to implement a Fibonacci heap.
    """
    def __init__(self):
        """Initialize an empty heap."""
        self.items = {}
    
    def __len__(self):
        """Return the number of items in the heap as an int."""
        return len(self.items)
    
    def insert(self, item, item_key):
        """
        Insert a new item with key item_key to the heap.
        
        If the item was already in the heap just update its key.
        """
        self.items[item] = item_key
    
    def decrease_key(self, item, new_item_key):
        """Update the item's key in the heap."""
        self.items[item] = new_item_key
    
    def pop(self):
        """
        Remove and return the item with the lowest key currently in 
        the heap; None if the heap is empty.
        """
        min_item = None
        min_key = float("inf")
        for item, key in self.items.items():
            if key < min_key:
                min_item = item
                min_key = key
        return min_item


@@ -320,17 +320,17 @@
  = %5B
-%22
+'
 DictHeap
 %22%5D%0A%0A
@@ -325,17 +325,17 @@
 DictHeap
-%22
+'
 %5D%0A%0A%0Aclas
@@ -813,24 +813,108 @@
 p.%0A        %0A
+        item -- the item to be inserted%0A        item_key -- the item's key%0A        %0A
         If t
@@ -1078,16 +1078,25 @@
      %22%22%22
+%0A        
 Update t
@@ -1117,24 +1117,87 @@
 in the heap.
+%0A        %0A        This can even increase the item key.%0A        
 %22%22%22%0A        
@@ -1332,25 +1332,16 @@
 ntly in 
-%0A        
 the heap
@@ -1341,16 +1341,32 @@
 he heap;
+ %0A        return
  None if
@@ -1449,13 +1449,13 @@
 oat(
-%22inf%22
+'inf'
 )%0A  
@@ -1613,9 +1613,8 @@
 in_item%0A
-%0A

Improve method docstrings a bit