diff options
author | Zhongheng Liu <z.liu@outlook.com.gr> | 2024-11-25 20:38:03 +0200 |
---|---|---|
committer | Zhongheng Liu <z.liu@outlook.com.gr> | 2024-11-25 20:38:03 +0200 |
commit | 4531afb7137e85dbdc45ec9147612a101568a507 (patch) | |
tree | 473fcf5b2e0ab7b1852ca7749b91231d797e2e73 /adt-queue/queue.py | |
parent | 5df83b0e15a757b4803b66b9af6a7e5afcd1667e (diff) | |
download | cs-y13-4531afb7137e85dbdc45ec9147612a101568a507.tar.gz cs-y13-4531afb7137e85dbdc45ec9147612a101568a507.tar.bz2 cs-y13-4531afb7137e85dbdc45ec9147612a101568a507.zip |
chore: move and rename
Diffstat (limited to 'adt-queue/queue.py')
-rw-r--r-- | adt-queue/queue.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/adt-queue/queue.py b/adt-queue/queue.py new file mode 100644 index 0000000..4235a7f --- /dev/null +++ b/adt-queue/queue.py @@ -0,0 +1,23 @@ +queue = [None for index in range(0, 10)] +frontPointer = 0 +rearPointer = -1 +queueLength = 0 +queueFull = 10 +def dequeue(): + global queue, queueLength, queueFull, rearPointer + +def enqueue(item): + global queue, queueLength, queueFull, rearPointer + if queueLength < queueFull: + if rearPointer < len(queue) - 1: + rearPointer += 1 + else: + rearPointer = 0 + queueLength += 1 + queue[rearPointer] = item + print(queue) + return + print("ERROR queue length exceeded!") + return +for i in range(13): + enqueue(10 * i) |