LinkedList Package
Project description
Py-linkedlist
Work with linkedlists datastructure in Python
Installation
pip install py-linkedlist
Import Package
# Importing linkedlist to your code
from linkedlist import linkedlist
Creating First Linkedlist
Initializing a linkedlist
l_list = linkedlist()
Adding Elements in the Linkedlist
#Adding First element to the linkedlist
l_list.add(10)
# Appending a list to the linkedlist
l_list.add([1, 2])
# Appending a tuple to the linkedlist
l_list.add((3, 4, 3))
# Adding new element at head position in linkedlist
l_list.addAtHead(20)
Any data type including String, Dictonary, Sets etc. can be added to linkedlist
Printing the Linkedlist
# Priting the linkedlist to console
l_list.show()
output: 20->10->1->2->3->4->3
Get Linkedlist length
# Returns length of linkedlist
print(l_list.length())
output: 7
Deleting Linkedlist elements
# Remove first occurance of an element (3)
# l_list: 20->10->1->2->3->4->3
l_list.removeElement(3)
l_list.show()
output: 20->10->1->2->4->3
# Remove using element position
# l_list: 20->10->1->2->4->3
l_list.removeAtLoc(2)
l_list.show()
output: 20->1->2->4->3
# Remove Head/First element in linkedlist
# l_list: 20->1->2->4->3
l_list.removeHead()
l_list.show()
output: 1->2->4->3
# Remove Tail/Last element in linkedlist
# l_list: 1->2->4->3
l_list.removeTail()
l_list.show()
output: 1->2->4
# Remove All elements in linkedlist
# l_list: 1->2->4->3
l_list.removeAll()
l_list.show()
output: None
Checking Linkedlist is Empty/Not
# Checking the linkedlist is Empty/Not
print(l_list.isEmpty())
output: True
Get Linkedlist element with location
# Get Linkedlist with location. Linkedlist are zero-indexed
l_list.add((13, 41, 34))
print(l_list.eleAt(2))
output: 34
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
py_linkedlist-0.0.10.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for py_linkedlist-0.0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d169965c661d9776d7fe3d7de17ea8495445f85643c2648a508b90f073b38f4 |
|
MD5 | 975278ee275093f6e4e0859c9716dc42 |
|
BLAKE2b-256 | 1353fa458502c0ae862622aed6a743052bb233ad0f1d66049075e3ce94b80ea8 |