Esempio n. 1
0
 def test_dequeue(self):
     queue = Queue()
     queue.enqueue(1)
     queue.enqueue(2)
     queue.enqueue(3)
     self.assertEqual(queue.dequeue(), 1)
     self.assertEqual(queue.dequeue(), 2)
     self.assertEqual(queue.dequeue(), 3)
Esempio n. 2
0
 def test_queue_002(self):
     q = Queue()
     self.assertTrue(q.is_empty())
     q.enqueue('A')
     self.assertFalse(q.is_empty())
     self.assertFalse(q.is_empty())
     self.assertEqual(q.dequeue(), 'A')
     self.assertTrue(q.is_empty())
Esempio n. 3
0
 def test_queue_003(self):
     q = Queue()
     self.assertTrue(q.is_empty())
     with self.assertRaises(QueueIsEmptyException):
         self.assertEqual(q.dequeue(), 'A')
Esempio n. 4
0
from stack import Queue
# s = Stack() #
# s.push(32)  # 32
# s.push(7)   # 7 32
# d = s.pop() # 32 and d holds 7
# s.push(d)   # 7 32
# s.pop()     # 32


q = Queue()     # []
q.enqueue(32)   # [32]
d = q.dequeue() # []
print(d)      # 32
q.enqueue(32)   # [32]
q.enqueue(7)    # [32 7]
d = q.dequeue() # [7] d = 32
print(d)
q.enqueue(32)   # [7 32]
a = q.peek()    # 7 32 and a holds 32
print(a)
print(q.size())
d = q.dequeue()
dd = q.dequeue()

print(d)
print(dd)


for i in range(0,10):
    q.enqueue(i)