[code.view]

[top] / python / PyMOTW / heapq / heapq_heapreplace.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2008 Doug Hellmann All rights reserved.
     #
     """
     """
     
     __version__ = "$Id$"
     #end_pymotw_header
     
     import heapq
     from heapq_showtree import show_tree
     from heapq_heapdata import data
     
     heapq.heapify(data)
     print 'start:'
     show_tree(data)
     
     for n in [0, 7, 13, 9, 5]:
         smallest = heapq.heapreplace(data, n)
         print 'replace %2d with %2d:' % (smallest, n)
         show_tree(data)

[top] / python / PyMOTW / heapq / heapq_heapreplace.py

contact | logmethods.com