-
Notifications
You must be signed in to change notification settings - Fork 0
/
Queues.py
57 lines (42 loc) · 1.12 KB
/
Queues.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Python program to
# demonstrate implementation of
# queue using queue module
from queue import Queue
from qjetdatabase import *
database = r"C:\Users\Deadsec\Desktop\QJet\Qjet\qjetdatabase.db"
connection = CreateConnection(database)
c = connection.cursor()
c.execute("SELECT Firstname FROM Member")
data = c.fetchall()
print(data)
firstName = []
for firstname in data:
for firstnameList in firstname:
firstName.append(firstnameList)
print(firstName)
lengthList = len(firstName)
# Initializing a queue
q = Queue(maxsize = lengthList)
# qsize() give the maxsize
# of the Queue
print(q.qsize())
# Adding of element to queue
for i in range(lengthList):
q.put(firstName[i])
# Return Boolean for Full
# Queue
print("\nFull: ", q.full())
# Removing element from queue
print("\nElements dequeued from the queue")
print(q.get())
print(q.get())
print(q.get())
# Return Boolean for Empty
# Queue
print("\nEmpty: ", q.empty())
q.put(1)
print("\nEmpty: ", q.empty())
print("Full: ", q.full())
# This would result into Infinite
# Loop as the Queue is empty.
# print(q.get())