Circular Queue
A pythonic implementation of the beloved data structure
Circular Queue is an object that can be used whenever you need to connect the head of an iterable to its tail. It can be easily connected to a database in order to persist your queue rotation.
Installation
pip install circular-queue
How to use
After cloning the repo, you can import the CircularQueue class to your project:
from circular_queue import CircularQueue
You can instantiate the CircularQueue object passing a queue an a pointer as arguments:
mylist = ['Banana', 'Star Fruit', 'Apple', 'Orange', 'Avocado']
pointer = 'Apple'
myqueue = CircularQueue(mylist, pointer)
Now you have two methods at your disposal: get_next_element and get_previous_element:
myqueue.get_next_element()
>>> 'Orange'
myqueue.get_next_element()
>>> 'Avocado'
myqueue.get_next_element()
>>> 'Banana'
myqueue.get_previous_element()
>>> 'Avocado'
If you need to get a batch of elements you can use the get_batch method like so:
mylist = ['Banana', 'Star Fruit', 'Apple', 'Orange', 'Avocado']
pointer = 'Banana'
batch_size = 3
myqueue = CircularQueue(mylist, pointer)
myqueue.get_batch(batch_size)
>>> ['Star Fruit', 'Apple', 'Orange']
You can also get batch elements in queue rotating to the left:
myqueue.get_batch(batch_size, rotation='left')
>>> ['Orange', 'Apple', 'Star Fruit']
Metadata
Release files for circular-queue 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| circular_queue-0.0.3.tar.gz | 3.6 kB | Without provenance | Details for circular_queue-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| circular_queue-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for circular_queue-0.0.3-py3-none-any.whl |
Total release size: 7.0 kB
Release files / circular_queue-0.0.3.tar.gz
| Download URL | circular_queue-0.0.3.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66cb224b52e7ed74ae635309b30cda94c14d2f37e4b4bca331f0cc66cf185a6f
|
|
BLAKE2b-256 checksum How to use checksums |
cf9ff3d4f2f48571fda82a997ddbcf88421dcac42e166e4a98d85e4bbacc31d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.9
|
Release files / circular_queue-0.0.3-py3-none-any.whl
| Download URL | circular_queue-0.0.3-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
edc43a648a452315ebbb6fa77e3f65a767a86bd99909a5f1b190c8154805c729
|
|
BLAKE2b-256 checksum How to use checksums |
8ae5bb8029329e63950075ac270ec22d6df4af216008755fa343a92c941d7e6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.9
|
Security for circular-queue 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.