import queue def GetItemList(q): ret = [] n = q.qsize() while n>0: ret.append(q.get()) n -= 1 return ret l = 'apple,banana,orange' #queue test q = queue.Queue() for x in l.split(','): print(x) q.put(x) print( GetItemList(q) ) #stack case #LIFO last in first out q = queue.LifoQueue() for x in l.split(','): q.put(x) print( GetItemList(q) ) #priorityQueue q = queue.PriorityQueue() q.put((5,"apple")) q.put((10,"banana")) q.put((1,"orange")) print( GetItemList(q) ) """ out put is... ['apple', 'banana', 'orange'] ['orange', 'banana', 'apple'] [(1, 'orange'), (5, 'apple'), (10, 'banana')] """
3/18/2014
Python Study, queue, stack, priority queue, example source code
Subscribe to:
Post Comments (Atom)
-
I use MOG2 algorithm to background subtraction. The process is resize to small for more fast processing to blur for avoid noise affectio...
-
fig 1. Left: set 4 points (Left Top, Right Top, Right Bottom, Left Bottom), right:warped image to (0,0) (300,0), (300,300), (0,300) Fi...
-
Image size of origin is 320*240. Processing time is 30.96 second took. The result of stitching The resul...
-
Created Date : 2011.2 Language : C/C++ Tool : Microsoft Visual C++ 2010 Library & Utilized : OpenCV 2.2 Reference : Interent Refer...
-
Created Date : 2009.10. Language : C++ Tool : Visual Studio C++ 2008 Library & Utilized : Point Grey-FlyCapture, Triclops, OpenCV...
-
refer to this web page -> http://docs.opencv.org/trunk/doc/py_tutorials/py_video/py_lucas_kanade/py_lucas_kanade.html dense optical f...
-
* Introduction - The solution shows panorama image from multi images. The panorama images is processing by real-time stitching algorithm...
-
In the YUV color format, Y is bright information, U is blue color area, V is red color area. Show the below picture. The picture is u-v col...
-
After training SVM, we should test the trained XML data is reliable or not.. The method to extract HOG feature is refer to -> http://fe...
-
Created Date : 2011.8 Language : Matlab Tool : Matlab 2010 Library & Utilized : - Reference : Multiple View Geometry (Hartly and Z...
No comments:
Post a Comment