[Python-checkins] python/dist/src/Lib/test test_heapq.py,1.5,1.6

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
2002年8月03日 03:10:12 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv29493/python/Lib/test
Modified Files:
	test_heapq.py 
Log Message:
Added new heapreplace(heap, item) function, to pop (and return) the
currently-smallest value, and add item, in one gulp. See the second
N-Best algorithm in the test suite for a natural use.
Index: test_heapq.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_heapq.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** test_heapq.py	3 Aug 2002 02:11:26 -0000	1.5
--- test_heapq.py	3 Aug 2002 10:10:10 -0000	1.6
***************
*** 3,7 ****
 from test.test_support import verify, vereq, verbose, TestFailed
 
! from heapq import heappush, heappop, heapify
 import random
 
--- 3,7 ----
 from test.test_support import verify, vereq, verbose, TestFailed
 
! from heapq import heappush, heappop, heapify, heapreplace
 import random
 
***************
*** 69,74 ****
 for item in data[10:]:
 if item > heap[0]: # this gets rarer the longer we run
! heappop(heap) # we know heap[0] isn't in best 10 anymore
! heappush(heap, item)
 vereq(list(heapiter(heap)), data_sorted[-10:])
 # Make user happy
--- 69,73 ----
 for item in data[10:]:
 if item > heap[0]: # this gets rarer the longer we run
! heapreplace(heap, item)
 vereq(list(heapiter(heap)), data_sorted[-10:])
 # Make user happy

AltStyle によって変換されたページ (->オリジナル) /