Sophisticate Linked Stack
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lstack-1.1.1.tar.gz.
File metadata
- Download URL: lstack-1.1.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7b98a9d603880f5349b6cece78fdf6367a024e44274f24329dfdb3724332663
|
|
| MD5 |
5b9f3f531cb09fb49ea25ae3c133ec54
|
|
| BLAKE2b-256 |
f977294683c6d8ec94cf23a893f92f8f6c06e99757919761c999cb00e826e24f
|
File details
Details for the file lstack-1.1.1-py3-none-any.whl.
File metadata
- Download URL: lstack-1.1.1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4df139b6230c2a3427e83836244af9c19213c10f1dafa93954c36516cf421de9
|
|
| MD5 |
9a3c764278f44dd6e1ef7efe849e5080
|
|
| BLAKE2b-256 |
08c3d675b5af839eed32062bdcb96096d818f686710e94d99778c9eed26f4722
|