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)
-
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...
-
In past, I wrote an articel about YUV 444, 422, 411 introduction and yuv <-> rgb converting example code. refer to this page -> ht...
-
As you can see in the following video, I created a class that stitching n cameras in real time. https://www.youtube.com/user/feelmare/sear...
-
This is data acquisition source code of LMS511(SICK co.) Source code is made by MFC(vs 2008). The sensor is communicated by TCP/IP. ...
-
Logistic Classifier The logistic classifier is similar to equation of the plane. W is weight vector, X is input vector and y is output...
-
* Introduction - The solution shows panorama image from multi images. The panorama images is processing by real-time stitching algorithm...
-
My Environment : MS VS 2008 & MFC(Dialog Based) Joy Stick : Logitech Extreme 3D pro (XBox Type) Cteated Date : 2012. 03 [source code]...
-
This is dithering example, it make image like a stippling effect. I referenced to blew website. wiki page: https://en.wikipedia.org/wik...
-
When we study cuda firstly, thread indexing is very confusing. So I tried to clean up. First, Let's grab a sense of looking at ...
-
This article explain how to access the thread index when you make block and thread with two dimensions. please refer to this page about me...
No comments:
Post a Comment