Stack.py
Stack.py is the LIFO Stack & FIFO Queue Implementation in Python. It is not a different data type, but can be treated as one.
LIFO - Last In, First Out. The last element to get in will be the first to get out.
FIFO - First In, First Out. The first element to get in will be the first to get out.
Badges
Provided By: shields.io
Acknowledgements
Authors
Installation
Easiest way is to install stack.py with pip
pip install stack.py
Usage / Examples
Stack
from stack import Stack
s = Stack(6) # Create a LIFO stack with stack length 6
s.put(1) # Pushing some elements to the stack
s.put(2)
s.put(3)
s.get() # Gets an element from the stack, pops it
s.list # Returns the elements of stack as a list
s.top # Returns the index of top pointer of the stack
s.list[s.top] # Returns the value of the element at top
s.empty # Returns True if the stack is empty else returns False
s.clear() # Clears the stack, and makes it empty
p = s.copy() # Creates a copy of stack as an independent object
print(s) # Prints the element of stacks as a stringified list
print(repr(s)) # Returns the class object representation of the stack with the values it holds
Queue
from stack import Queue
q = Queue(10) # Create a FIFO queue with queue length 6
q.enqueue(1) # Enqueues elements to the queue
q.enqueue(2)
q.enqueue(3)
q.dequeue() # Gets an element from the queue, pops it
q.list # Returns the elements of queue as a list
q.front # Returns the index of front pointer of the stack
q.rear # Returns the index of rear pointer of the stack
q.list[s.rear] # Returns the value of the rear element
q.empty # Returns True if the queue is empty else returns False
q.clear() # Clears the queue, and makes it empty
t = q.copy() # Creates a copy of stack as an independent object
print(q) # Prints the element of queue as a stringified list
print(repr(q)) # Returns the class object representation of the queue with the values it holds
Contributing
Contributions are always welcome!
- Fork this repository.
- Make the changes in your forked repositry.
- Generate a pull request.
Please adhere to the GitHub's code of conduct.
License
Metadata
Release files for stack.py 2.0
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 |
|---|---|---|---|---|
| stack.py-2.0.tar.gz | 7.7 kB | Without provenance | Details for stack.py-2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stack.py-2.0-py3-none-any.whl | Python 3 | none | any | Details for stack.py-2.0-py3-none-any.whl |
Total release size: 15.6 kB
Release files / stack.py-2.0.tar.gz
| Download URL | stack.py-2.0.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
50de015823048ffd2bd432ae46be25211ee102fa7710240726b548745d280760
|
|
BLAKE2b-256 checksum How to use checksums |
255edb5582b9910c2a13e09f025aba12944c0809259bee496128637edbceac9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.6
|
Release files / stack.py-2.0-py3-none-any.whl
| Download URL | stack.py-2.0-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ddda2956c43c35767736f0ce87ac7ae9d46f62b610ec5c6753f561b3550fd345
|
|
BLAKE2b-256 checksum How to use checksums |
2d3815681f51a005bd7f5344d784dd9c6264c45e210fc3f2ec192d480afb956a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.6
|
Security for stack.py 2.0
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.