本文整理汇总了Python中queue.Queue.deq方法的典型用法代码示例。如果您正苦于以下问题:Python Queue.deq方法的具体用法?Python Queue.deq怎么用?Python Queue.deq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类queue.Queue
的用法示例。
在下文中一共展示了Queue.deq方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: komsuBul
# 需要导入模块: from queue import Queue [as 别名]
# 或者: from queue.Queue import deq [as 别名]
y = b + 1
x = a
liste.append([x,y])
x, y = 0, 0
durum += 1
return liste
mat = [[12,34,52,99,23],
[12,1,14,21,23],
[12,18,22,23,19],
[16,28,24,44,23],
[8,12,23,46,34]]
x ,y = 2,2
noktalar.enq([x,y])
gezilen =[]
while not noktalar.isEmpty() and y<3:
nokta = noktalar.deq()
x, y = nokta[0], nokta[1]
komsular = komsuBul(x,y)
for i in komsular:
if mat[x][y] - 5 <= mat[i[0]][i[1]] <= mat[x][y] + 5 :
if [i[0], i[1]] not in gezilen:
gezilen.append([i[0], i[1]])
noktalar.enq([i[0], i[1]])
for i in gezilen:
mat[i[0]][i[1]]= 0
for i in range(5):
print mat[i]
示例2: __init__
# 需要导入模块: from queue import Queue [as 别名]
# 或者: from queue.Queue import deq [as 别名]
class Simulator:
# time quantum, processes
def __init__(self, tq=2):
self.quantum = tq
self.procs = []
self.clock = 0
self.queue = Queue()
self.events = []
self.timer = 0
# time quantum
def quantize(self, tq=2):
self.quantum = tq
# create procces and add to list
def process(self, pname, pat, pbt):
self.procs.append(Process(pname, pat, pbt))
# create process from csv ';' file and add to list
def load(self, path):
with open(path) as file:
content = file.read()
lines = content.split('\n')
for line in lines:
if line.strip():
data = line.strip().split(';')
n = data[0].strip()
at = int(data[1].strip())
bt = int(data[2].strip())
self.process(n, at, bt)
# listen for arriving
def catch(self):
temp = [] # to store enqueued processed to be removed from list
for proc in self.procs:
if proc.arrive == self.clock:
self.queue.enq(proc)
temp.append(proc)
for proc in temp:
self.procs.remove(proc)
def run(self):
proc = self.queue.deq()
complete = False
if proc.burst > self.quantum:
time = self.quantum
else:
time = proc.burst
complete = True
event = Event(proc.name, self.timer, self.timer + time)
self.events.append(event)
self.timer += time
if not complete:
proc.burst -= time
self.queue.enq(proc)
def schedule(self):
while self.clock < MAX_CLOCK:
self.catch()
if not self.queue.empty():
self.run()
self.clock += 1