mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-24 09:21:24 -04:00
abstracted structures fixed
This commit is contained in:
parent
3fdbc2a605
commit
01703751f1
98 changed files with 305 additions and 856 deletions
|
@ -1,27 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
__author__ = "bt3"
|
||||
|
||||
|
||||
class Queue(object):
|
||||
def __init__(self):
|
||||
self.enq = []
|
||||
self.deq = []
|
||||
|
||||
def enqueue(self, value):
|
||||
self.enq.append(value)
|
||||
|
||||
def dequeue(self):
|
||||
if not self.deq:
|
||||
while self.enq:
|
||||
self.deq.append(self.enq.pop())
|
||||
return self.deq.pop()
|
||||
|
||||
if __name__ == '__main__':
|
||||
q = Queue()
|
||||
|
||||
for i in range(1,10):
|
||||
q.enqueue(i)
|
||||
|
||||
for i in range(1, 10):
|
||||
print q.dequeue()
|
Loading…
Add table
Add a link
Reference in a new issue