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)
-
The latent SVM tells the learning method used in this paper -> "Discriminatively trained deformable part models". The authors s...
-
In past, I wrote an articel about YUV 444, 422, 411 introduction and yuv rgb converting example code. refer to this page -> http://feel...
-
My Environment : MS VS 2008 & MFC(Dialog Based) Joy Stick : Logitech Extreme 3D pro (XBox Type) Cteated Date : 2012. 03 [source code]...
-
refer to code: .. import torch # create a tensor x = torch . randn ( 3 , 4 ) # set print options to display full tensor torch . set_print...
-
Creating a custom CUDA kernel that directly utilizes tensor cores is an advanced topic, as tensor cores are typically accessed through highe...
-
Created Date : 2011.10 Language : C/C++ Tool : Microsoft Visual C++ 2008 Library & Utilized : OpenCV 2.3 Reference : SIFT referenc...
-
KEY KeyCode ASCII KEY KeyCode ASCII 0 48 48 Numpad 0 96 48 1 49 49 Numpad 1 97 49 2 50 50 Num...
-
yolo v5 data coordinate format ex) str_v = "32 0.262 0.7878 0.314 0.385" #read image cvmat = cv2.imread(img_path) #get height, w...
-
Example 1: Basic Variadic Template # include <iostream> // 1. Simple function that accepts any number of arguments template ...
-
Optical Flow sample source code using OpenCV. It programed based on http://feelmare.blogspot.kr/2012/10/make-2-frame-having-time-interv...
No comments:
Post a Comment