Sophisticate Circular Queue
Project description
cqueue
This library was created to make the concept of a queue easier by visualizing it and showing how items enter and exit it, especially for beginners in data structures
Installation
You can install cqueue
via pip:
pip install cqueue
Usage
For Circular Queue
from cqueue import circularQueue
x = circularQueue(capacity=7)
print(x)
Output
[]
You Can Visualize The Queue With All Details
from cqueue import circularQueue
x = circularQueue(capacity=7, detail=True)
print(x)
Output
╒═════════╤══╤══╤══╤══╤══╤══╤══╤══════════╕
│ <- EXIT │ │ │ │ │ │ │ │ <- ENTER │
╘═════════╧══╧══╧══╧══╧══╧══╧══╧══════════╛
Enqueue
from cqueue import circularQueue
x = circularQueue(capacity=7, detail=True)
print(x)
x.enqueue(1)
x.enqueue(2)
x.enqueue(3)
print(x)
Output
╒═════════╤══╤══╤══╤══╤══╤══╤══╤══════════╕
│ <- EXIT │ │ │ │ │ │ │ │ <- ENTER │
╘═════════╧══╧══╧══╧══╧══╧══╧══╧══════════╛
╒═════════╤═══╤═══╤═══╤══╤══╤══╤══╤══════════╕
│ <- EXIT │ 1 │ 2 │ 3 │ │ │ │ │ <- ENTER │
╘═════════╧═══╧═══╧═══╧══╧══╧══╧══╧══════════╛
Dequeue
from cqueue import circularQueue
x = circularQueue([1, 2, 3], capacity=7, detail=True)
print(x)
x.dequeue()
print(x)
Output
╒═════════╤═══╤═══╤═══╤══╤══╤══╤══╤══════════╕
│ <- EXIT │ 1 │ 2 │ 3 │ │ │ │ │ <- ENTER │
╘═════════╧═══╧═══╧═══╧══╧══╧══╧══╧══════════╛
╒═════════╤═══╤═══╤══╤══╤══╤══╤══╤══════════╕
│ <- EXIT │ 2 │ 3 │ │ │ │ │ │ <- ENTER │
╘═════════╧═══╧═══╧══╧══╧══╧══╧══╧══════════╛
You Can Check If The Queue Is Empty Or Not
from cqueue import circularQueue
x = circularQueue(capacity=7, detail=True)
print(x.isEmpty())
Output
True
You Can Check If The Queue Is Full Or Not
from cqueue import circularQueue
x = circularQueue([1, 2, 3, 4, 5, 6, 7], capacity=7, detail=True)
print(x.isFull())
Output
True
You Can See The Item Who Can EXIT From The Queue Using peek Or top
from cqueue import circularQueue
x = circularQueue([5, 6, 7], capacity=7, detail=True)
print(x.peek())
print(x.top())
Output
5
5
You Can See How Many Items Are In The Queue Using len Function
from cqueue import circularQueue
x = circularQueue([5, 6, 7], capacity=7, detail=True)
print(len(x))
Output
3
You Can Clear The Queue
from cqueue import circularQueue
x = circularQueue([5, 6, 7], capacity=7, detail=True)
print(x)
x.clear()
print(x)
Output
╒═════════╤═══╤═══╤═══╤══╤══╤══╤══╤══════════╕
│ <- EXIT │ 5 │ 6 │ 7 │ │ │ │ │ <- ENTER │
╘═════════╧═══╧═══╧═══╧══╧══╧══╧══╧══════════╛
╒═════════╤══╤══╤══╤══╤══╤══╤══╤══════════╕
│ <- EXIT │ │ │ │ │ │ │ │ <- ENTER │
╘═════════╧══╧══╧══╧══╧══╧══╧══╧══════════╛
For Linked Circular Queue
You can use linkedCircularQueue with the same syntax as circularQueue with all previous methods the main difference is circularQueue use static array(list) and linkedCircularQueue use static circular singly linked list
License
This project is licensed under the MIT LICENSE - see the LICENSE for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cqueue-1.1.2.tar.gz
(4.6 kB
view details)
Built Distribution
File details
Details for the file cqueue-1.1.2.tar.gz
.
File metadata
- Download URL: cqueue-1.1.2.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb6b6943feb508b7fc6535ba1065e1662193324152cca0e6d909421202cc03d0 |
|
MD5 | d6db8abb082a402466310534aab7c713 |
|
BLAKE2b-256 | 859da71ee234774b51c4a5b333b127993cfa24af14f050ee1d48db6727b2a09f |
File details
Details for the file cqueue-1.1.2-py3-none-any.whl
.
File metadata
- Download URL: cqueue-1.1.2-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77e956e35e2574628acc5973b7dd7257f74c0869452165ed0eb6da2e2c76450b |
|
MD5 | 388262bea8db09529b517a8a8cead020 |
|
BLAKE2b-256 | 1d81aa0f989b4a2407bcab10cb56861bcd068c933ebd211bada808452d80f1c4 |