Skip to main content

Sophisticate Court Queue

Project description

court-queue

PyPI version License

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

court-queue-1.0.0.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

court_queue-1.0.0-py3-none-any.whl (5.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page