Skip to main content

Sophisticate Linked Stack

Project description

lstack

PyPI version License: MIT

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lstack-1.1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

lstack-1.1.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

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

Hashes for lstack-1.1.1.tar.gz
Algorithm Hash digest
SHA256 f7b98a9d603880f5349b6cece78fdf6367a024e44274f24329dfdb3724332663
MD5 5b9f3f531cb09fb49ea25ae3c133ec54
BLAKE2b-256 f977294683c6d8ec94cf23a893f92f8f6c06e99757919761c999cb00e826e24f

See more details on using hashes here.

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

Hashes for lstack-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4df139b6230c2a3427e83836244af9c19213c10f1dafa93954c36516cf421de9
MD5 9a3c764278f44dd6e1ef7efe849e5080
BLAKE2b-256 08c3d675b5af839eed32062bdcb96096d818f686710e94d99778c9eed26f4722

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