Skip to main content

Sophisticate Court Queue

Project description

court-queue

PyPI version License: MIT

This library was created for modeling and simulating non-linear, snake-like queues as observed in high-density environments such as airports, stadiums, theme parks, courts, and other crowd-controlled areas. Traditional queue structures typically operate in a simple, linear order; however, non-linear queues take a more spatially efficient, serpentine form, allowing for greater throughput within confined spaces while preserving orderly progression.

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 MIT LICENSE - see the LICENSE for more details.

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.4.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

court_queue-1.0.4-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file court-queue-1.0.4.tar.gz.

File metadata

  • Download URL: court-queue-1.0.4.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for court-queue-1.0.4.tar.gz
Algorithm Hash digest
SHA256 13f25dc6e0542c746476801c6b74bdf0f229ee6e226e48b1cc8f479cd6051e9e
MD5 b39d89cea19def1333e2166abd985f41
BLAKE2b-256 c2bc644910f4abf009aad449c69cfba6f52cbe3cdc2af123d2b8cde2b9dfdf46

See more details on using hashes here.

File details

Details for the file court_queue-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: court_queue-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for court_queue-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 defddf1899ddf500c6e89efe2d3307ab64bc1145bb336d00b51d9fec97974c9d
MD5 66d19e1d64eb4f555dee88dc6725fee2
BLAKE2b-256 25188b558d50a2a4de32c62cbc57e326f8ecbed96e4c7f04008c21c59a0804ee

See more details on using hashes here.

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