Sophisticate Court Queue
Project description
court-queue
This library provides tools to visualize and work with a novel data structure known as the 'court queue.' The court queue combines the concepts of 2D arrays and right/left queues to create a multi-level queue system with specific rules for adding, removing, and moving elements between levels. It’s designed to offer a structured and efficient approach to managing hierarchical data or tasks.
Whether you're a beginner or a professional, this library is tailored to suit various levels of expertise, providing both straightforward and advanced features for working with the court queue data structure.
Installation
You can install court-queue
via pip:
pip install court-queue
Usage
You can create the queue from a predefined, static 2D array (matrix)
from court_queue import courtQueue
static_matrix = [[1, 2, 3], [6, 5, 4], [7, 8, 9]]
x = courtQueue(static_matrix)
print(x)
Output
[[1, 2, 3], [6, 5, 4], [7, 8, 9]]
You can show all details
from court_queue import courtQueue
static_matrix = [[1, 2, 3], [6, 5, 4], [7, 8, 9]]
x = courtQueue(static_matrix, detail=True)
print(x)
Output
╒══════════╤═══╤═══╤═══╤══════════╕
│ <- EXIT │ 1 │ 2 │ 3 │ <- ENTER │
├──────────┼───┼───┼───┼──────────┤
│ ENTER -> │ 6 │ 5 │ 4 │ EXIT ^ │
├──────────┼───┼───┼───┼──────────┤
│ ^ EXIT │ 7 │ 8 │ 9 │ <- ENTER │
╘══════════╧═══╧═══╧═══╧══════════╛
You can dequeue values
from court_queue import courtQueue
static_matrix = [[1, 2, 3], [6, 5, 4], [7, 8, 9]]
x = courtQueue(static_matrix, detail=True)
print(x)
x.dequeue()
print(x)
Output
╒══════════╤═══╤═══╤═══╤══════════╕
│ <- EXIT │ 1 │ 2 │ 3 │ <- ENTER │
├──────────┼───┼───┼───┼──────────┤
│ ENTER -> │ 6 │ 5 │ 4 │ EXIT ^ │
├──────────┼───┼───┼───┼──────────┤
│ ^ EXIT │ 7 │ 8 │ 9 │ <- ENTER │
╘══════════╧═══╧═══╧═══╧══════════╛
╒══════════╤═══╤═══╤═══╤══════════╕
│ <- EXIT │ 2 │ 3 │ 4 │ <- ENTER │
├──────────┼───┼───┼───┼──────────┤
│ ENTER -> │ 7 │ 6 │ 5 │ EXIT ^ │
├──────────┼───┼───┼───┼──────────┤
│ ^ EXIT │ 8 │ 9 │ │ <- ENTER │
╘══════════╧═══╧═══╧═══╧══════════╛
You can enqueue values
from court_queue import courtQueue
static_matrix = [[1, 2, 3], [6, 5, 4], [7, 8, None]]
x = courtQueue(static_matrix, detail=True)
print(x)
x.enqueue(9)
print(x)
Output
╒══════════╤═══╤═══╤═══╤══════════╕
│ <- EXIT │ 1 │ 2 │ 3 │ <- ENTER │
├──────────┼───┼───┼───┼──────────┤
│ ENTER -> │ 6 │ 5 │ 4 │ EXIT ^ │
├──────────┼───┼───┼───┼──────────┤
│ ^ EXIT │ 7 │ 8 │ │ <- ENTER │
╘══════════╧═══╧═══╧═══╧══════════╛
╒══════════╤═══╤═══╤═══╤══════════╕
│ <- EXIT │ 1 │ 2 │ 3 │ <- ENTER │
├──────────┼───┼───┼───┼──────────┤
│ ENTER -> │ 6 │ 5 │ 4 │ EXIT ^ │
├──────────┼───┼───┼───┼──────────┤
│ ^ EXIT │ 7 │ 8 │ 9 │ <- ENTER │
╘══════════╧═══╧═══╧═══╧══════════╛
You can create the queue from scratch
from court_queue import courtQueue
x = courtQueue(rows=3, columns=3, detail=True)
print(x)
for i in range(9):
x.enqueue(i + 1)
print(x)
Output
╒══════════╤══╤══╤══╤══════════╕
│ <- EXIT │ │ │ │ <- ENTER │
├──────────┼──┼──┼──┼──────────┤
│ ENTER -> │ │ │ │ EXIT ^ │
├──────────┼──┼──┼──┼──────────┤
│ ^ EXIT │ │ │ │ <- ENTER │
╘══════════╧══╧══╧══╧══════════╛
╒══════════╤═══╤═══╤═══╤══════════╕
│ <- EXIT │ 1 │ 2 │ 3 │ <- ENTER │
├──────────┼───┼───┼───┼──────────┤
│ ENTER -> │ 6 │ 5 │ 4 │ EXIT ^ │
├──────────┼───┼───┼───┼──────────┤
│ ^ EXIT │ 7 │ 8 │ 9 │ <- ENTER │
╘══════════╧═══╧═══╧═══╧══════════╛
You can show how many values are in the queue
from court_queue import courtQueue
static_matrix = [[1, 2, 3], [6, 5, 4], [7, 8, 9]]
x = courtQueue(static_matrix, detail=True)
print(len(x))
Output
9
You can check whether the queue is empty
from court_queue import courtQueue
static_matrix = [[None, None, None], [None, None, None], [None, None, None]]
x = courtQueue(static_matrix, detail=True)
print(x.isEmpty())
x.enqueue(1)
print(x.isEmpty())
Output
True
False
You can check whether the queue is full
from court_queue import courtQueue
static_matrix = [[1, 2, 3], [6, 5, 4], [7, 8, 9]]
x = courtQueue(static_matrix, detail=True)
print(x.isFull())
x.dequeue()
print(x.isFull())
Output
True
False
You can check the next value to be dequeued using peek or top
from court_queue import courtQueue
static_matrix = [[1, 2, 3], [6, 5, 4], [7, 8, 9]]
x = courtQueue(static_matrix, detail=True)
print(x.peek())
print(x.top())
Output
1
1
You can clear all the values from the queue
from court_queue import courtQueue
static_matrix = [[1, 2, 3], [6, 5, 4], [7, 8, 9]]
x = courtQueue(static_matrix, detail=True)
print(x)
x.clear()
print(x)
Output
╒══════════╤═══╤═══╤═══╤══════════╕
│ <- EXIT │ 1 │ 2 │ 3 │ <- ENTER │
├──────────┼───┼───┼───┼──────────┤
│ ENTER -> │ 6 │ 5 │ 4 │ EXIT ^ │
├──────────┼───┼───┼───┼──────────┤
│ ^ EXIT │ 7 │ 8 │ 9 │ <- ENTER │
╘══════════╧═══╧═══╧═══╧══════════╛
╒══════════╤══╤══╤══╤══════════╕
│ <- EXIT │ │ │ │ <- ENTER │
├──────────┼──┼──┼──┼──────────┤
│ ENTER -> │ │ │ │ EXIT ^ │
├──────────┼──┼──┼──┼──────────┤
│ ^ EXIT │ │ │ │ <- ENTER │
╘══════════╧══╧══╧══╧══════════╛
License
This project is licensed under the Apache License 2.0 - see the LICENSE for more details.
Contributions
We invite developers and researchers to contribute ideas, improvements, or enhancements to the court queue data structure. Your innovative suggestions can help advance this project and expand its applications. While we welcome and encourage collaborative efforts, please note that the core concept and invention of the court queue remain the intellectual property of the original author. For inquiries or to discuss potential contributions, please contact khiat.dev@gmail.com.
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
Built Distribution
Hashes for court_queue-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d792c7c436339855ac3d64ef1a3a8f043fb02565106ea040316de3f1b27fb67 |
|
MD5 | 4f17f5b8d29216203e6f828fea6041fa |
|
BLAKE2b-256 | 5c4b0f01f4b6fa5d4659efc87d366260fb2a7c82350c7e60a203a4018e2889b8 |