lstack
This library was created to make the stack concept easier to understand by visualizing it and showing how objects enter and exit the stack, especially for beginners in data structures
Installation
You can install lstack via pip:
pip install lstack
Usage
For singlyLinkedStack
from lstack import singlyLinkedStack
x = singlyLinkedStack(capacity=7)
print(x)
Output
[]
You Can Visualize The Stack With All Details
from lstack import singlyLinkedStack
x = singlyLinkedStack(capacity=7, detail=True)
print(x)
Output
╒════════════╕
│ ENTER ^ │
│ | | │
│ v EXIT │
├────────────┤
├────────────┤
├────────────┤
├────────────┤
├────────────┤
├────────────┤
├────────────┤
╘════════════╛
Push
from lstack import singlyLinkedStack
x = singlyLinkedStack(capacity=7, detail=True)
print(x)
x.push(1)
x.push(2)
x.push(3)
print(x)
Output
╒════════════╕
│ ENTER ^ │
│ | | │
│ v EXIT │
├────────────┤
├────────────┤
├────────────┤
├────────────┤
├────────────┤
├────────────┤
├────────────┤
╘════════════╛
╒════════════╕
│ ENTER ^ │
│ | | │
│ v EXIT │
├────────────┤
├────────────┤
├────────────┤
├────────────┤
├────────────┤
│ 3 │
├────────────┤
│ 2 │
├────────────┤
│ 1 │
╘════════════╛
Pop
from lstack import singlyLinkedStack
x = singlyLinkedStack([1, 2, 3], capacity=7, detail=True)
print(x)
x.pop()
print(x)
Output
╒════════════╕
│ ENTER ^ │
│ | | │
│ v EXIT │
├────────────┤
├────────────┤
├────────────┤
├────────────┤
├────────────┤
│ 3 │
├────────────┤
│ 2 │
├────────────┤
│ 1 │
╘════════════╛
╒════════════╕
│ ENTER ^ │
│ | | │
│ v EXIT │
├────────────┤
├────────────┤
├────────────┤
├────────────┤
├────────────┤
├────────────┤
│ 2 │
├────────────┤
│ 1 │
╘════════════╛
You Can Check If The Stack Is Empty Or Not
from lstack import singlyLinkedStack
x = singlyLinkedStack(capacity=7, detail=True)
print(x.isEmpty())
Output
True
You Can Check If The Stack Is Full Or Not
from lstack import singlyLinkedStack
x = singlyLinkedStack([1, 2, 3, 4, 5, 6, 7], capacity=7, detail=True)
print(x.isFull())
Output
True
You Can See The Item Who Can EXIT From The Stack Using peek Or top
from lstack import singlyLinkedStack
x = singlyLinkedStack([5, 6, 7], capacity=7, detail=True)
print(x.peek())
print(x.top())
Output
7
7
You Can See How Many Items Are In The Stack Using len Function
from lstack import singlyLinkedStack
x = singlyLinkedStack([5, 6, 7], capacity=7, detail=True)
print(len(x))
Output
3
You Can Clear The Stack
from lstack import singlyLinkedStack
x = singlyLinkedStack([5, 6, 7], capacity=7, detail=True)
print(x)
x.clear()
print(x)
Output
╒════════════╕
│ ENTER ^ │
│ | | │
│ v EXIT │
├────────────┤
├────────────┤
├────────────┤
├────────────┤
├────────────┤
│ 7 │
├────────────┤
│ 6 │
├────────────┤
│ 5 │
╘════════════╛
╒════════════╕
│ ENTER ^ │
│ | | │
│ v EXIT │
├────────────┤
├────────────┤
├────────────┤
├────────────┤
├────────────┤
├────────────┤
├────────────┤
╘════════════╛
Note
You can use doublyLinkedStack with the same syntax as singlyLinkedStack with all previous methods the main difference is singlyLinkedStack use static non circular singly linked list and doublyLinkedStack use static non circular doubly linked list.
License
This project is licensed under the MIT LICENSE - see the LICENSE for more details.
Metadata
Release files for lstack 1.1.1
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 |
|---|---|---|---|---|
| lstack-1.1.1.tar.gz | 4.6 kB | Without provenance | Details for lstack-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lstack-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for lstack-1.1.1-py3-none-any.whl |
Total release size: 9.8 kB
Release files / lstack-1.1.1.tar.gz
| Download URL | lstack-1.1.1.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7b98a9d603880f5349b6cece78fdf6367a024e44274f24329dfdb3724332663
|
|
BLAKE2b-256 checksum How to use checksums |
f977294683c6d8ec94cf23a893f92f8f6c06e99757919761c999cb00e826e24f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.2
|
Release files / lstack-1.1.1-py3-none-any.whl
| Download URL | lstack-1.1.1-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4df139b6230c2a3427e83836244af9c19213c10f1dafa93954c36516cf421de9
|
|
BLAKE2b-256 checksum How to use checksums |
08c3d675b5af839eed32062bdcb96096d818f686710e94d99778c9eed26f4722
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.2
|
Security for lstack 1.1.1
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.