-
Notifications
You must be signed in to change notification settings - Fork 0
/
queue.py
43 lines (32 loc) · 769 Bytes
/
queue.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
__author__ = 'sarvps'
'''
Author: Sarv Parteek Singh
Course: CISC 610
Term: Late Summer
Data Structures & Algorithms by Miller
Quiz 1, Problem 3
'''
class Queue:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def enqueue(self, item):
self.items.append(item)
def dequeue(self):
return self.items.pop(0)
def size(self):
return len(self.items)
def getQueue(self):
return self.items
def main(): # for testing
q = Queue()
q.enqueue('dog')
print(q.getQueue())
q.enqueue('cat')
print(q.getQueue())
q.enqueue(3)
print(q.getQueue())
q.dequeue()
print(q.getQueue())
# main() #Uncomment to enable testing