linkedit
This library was created to facilitate the use of linked lists with the same ease as regular lists in Python, while presenting them in a clearer and more aesthetic way, especially for beginners in data structures.
Installation
You can install linkedit
via pip:
pip install linkedit
Usage
For Non Circular Singly Linked List
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7])
print(x)
Output
[6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -> None (NULL)
You Can See All Nodes Details
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7], detail=True)
print(x)
Output
โโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโ
โ Current Value โ Current Value @ddress โ Next Value โ Next Value @ddress โ
โโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโก
โ 6 โ 0x7febe8213950 โ 3 โ 0x7febe8213990 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 3 โ 0x7febe8213990 โ 8 โ 0x7febe82139d0 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 8 โ 0x7febe82139d0 โ 1 โ 0x7febe823c110 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 1 โ 0x7febe823c110 โ 9 โ 0x7febe805bd10 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 9 โ 0x7febe805bd10 โ 5 โ 0x7febe805bb50 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 5 โ 0x7febe805bb50 โ 7 โ 0x7febe805be50 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 7 โ 0x7febe805be50 โ None (NULL) โ 0x959cc0 (nil/0x0) โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ None (NULL) โ 0x959cc0 (nil/0x0) โ โ โ
โโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโ
You Can Change The Addresses Base From Hex(16) To Dec(10), Oct(8) Or Bin(2)
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7], detail=True, base=10)
print(x)
Output
โโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโ
โ Current Value โ Current Value @ddress โ Next Value โ Next Value @ddress โ
โโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโก
โ 6 โ 140217964133136 โ 3 โ 140217964133264 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 3 โ 140217964133264 โ 8 โ 140217964133200 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 8 โ 140217964133200 โ 1 โ 140217964298704 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 1 โ 140217964298704 โ 9 โ 140217962282256 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 9 โ 140217962282256 โ 5 โ 140217962281808 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 5 โ 140217962281808 โ 7 โ 140217962282576 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 7 โ 140217962282576 โ None (NULL) โ 9804992 (nil/0) โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ None (NULL) โ 9804992 (nil/0) โ โ โ
โโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโ
You Can Add The Items In An Orderly Ascending Or Descending Manner
ASC
from linkedit import singlyLinkedList
x = singlyLinkedList()
x.add(6)
x.add(3)
x.add(8)
x.add(1)
x.add(9)
x.add(5)
x.add(7)
print(x)
Output
[1] -> [3] -> [5] -> [6] -> [7] -> [8] -> [9] -> None (NULL)
DESC
from linkedit import singlyLinkedList
x = singlyLinkedList(reverse=True)
x.add(6)
x.add(3)
x.add(8)
x.add(1)
x.add(9)
x.add(5)
x.add(7)
print(x)
Output
[9] -> [8] -> [7] -> [6] -> [5] -> [3] -> [1] -> None (NULL)
You Can Check If The Linked List Is Empty Or Not
from linkedit import singlyLinkedList
x = singlyLinkedList()
print(x.isEmpty())
Output
True
You Can Do Right / Left Shifting
Right Shifting
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7])
print(x)
x >> 3
print(x)
Output
[6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -> None (NULL)
[9] -> [5] -> [7] -> [6] -> [3] -> [8] -> [1] -> None (NULL)
Left Shifting
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7])
print(x)
x << 3
print(x)
Output
[6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -> None (NULL)
[1] -> [9] -> [5] -> [7] -> [6] -> [3] -> [8] -> None (NULL)
You Can Insert A New Value In The First Of Linked List Directely With prepend
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7])
print(x)
x.prepend(0)
print(x)
Output
[6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -> None (NULL)
[0] -> [6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -> None (NULL)
You Can Change From Non Circular To Circular
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7])
print(x)
x.set_circular()
print(x)
Output
[6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -> None (NULL)
> [6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -
You Can Change From Singly To Doubly
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7])
print(x)
x = x.to_doubly()
print(x)
Output
[6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -> None (NULL)
None (NULL) <- [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] -> None (NULL)
You Can Create A Dictionary From The Linked List
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7])
y = x.to_dict()
print(x)
print(y)
Output
[6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -> None (NULL)
{6: {'current value @ddress': '0x7f64a3e13910', 'next value': 3, 'next value @ddress': '0x7f64a3e13a10'}, 3: {'current value @ddress': '0x7f64a3e13a10', 'next value': 8, 'next value @ddress': '0x7f64a3e13a50'}, 8: {'current value @ddress': '0x7f64a3e13a50', 'next value': 1, 'next value @ddress': '0x7f64a3e3c190'}, 1: {'current value @ddress': '0x7f64a3e3c190', 'next value': 9, 'next value @ddress': '0x7f64a3c1bc50'}, 9: {'current value @ddress': '0x7f64a3c1bc50', 'next value': 5, 'next value @ddress': '0x7f64a3c1ba90'}, 5: {'current value @ddress': '0x7f64a3c1ba90', 'next value': 7, 'next value @ddress': '0x7f64a3c1bd90'}, 7: {'current value @ddress': '0x7f64a3c1bd90', 'next value': None, 'next value @ddress': '0x959cc0'}}
For Circular Singly Linked List
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True)
print(x)
Output
> [6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -
With All Nodes Details
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True, detail=True)
print(x)
Output
โโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโ
โ Current Value โ Current Value @ddress โ Next Value โ Next Value @ddress โ
โโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโก
โ 6 โ 0x7fbe38bf3ad0 โ 3 โ 0x7fbe38bf3b50 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 3 โ 0x7fbe38bf3b50 โ 8 โ 0x7fbe38bf3b10 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 8 โ 0x7fbe38bf3b10 โ 1 โ 0x7fbe38c07fd0 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 1 โ 0x7fbe38c07fd0 โ 9 โ 0x7fbe38a07c50 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 9 โ 0x7fbe38a07c50 โ 5 โ 0x7fbe38a07a90 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 5 โ 0x7fbe38a07a90 โ 7 โ 0x7fbe38a07d90 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 7 โ 0x7fbe38a07d90 โ 6 โ 0x7fbe38bf3ad0 โ
โโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโ
With Dec(10) Base
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True, detail=True, base=10)
print(x)
Output
โโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโ
โ Current Value โ Current Value @ddress โ Next Value โ Next Value @ddress โ
โโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโก
โ 6 โ 140374800546256 โ 3 โ 140374800546448 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 3 โ 140374800546448 โ 8 โ 140374800546192 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 8 โ 140374800546192 โ 1 โ 140374800629712 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 1 โ 140374800629712 โ 9 โ 140374798531664 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 9 โ 140374798531664 โ 5 โ 140374798531216 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 5 โ 140374798531216 โ 7 โ 140374798531984 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 7 โ 140374798531984 โ 6 โ 140374800546256 โ
โโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโ
Adding Items In An Orderly Ascending And Descending Manner
ASC
from linkedit import singlyLinkedList
x = singlyLinkedList(circular=True)
x.add(6)
x.add(3)
x.add(8)
x.add(1)
x.add(9)
x.add(5)
x.add(7)
print(x)
Output
> [1] -> [3] -> [5] -> [6] -> [7] -> [8] -> [9] -
DESC
from linkedit import singlyLinkedList
x = singlyLinkedList(circular=True, reverse=True)
x.add(6)
x.add(3)
x.add(8)
x.add(1)
x.add(9)
x.add(5)
x.add(7)
print(x)
Output
> [9] -> [8] -> [7] -> [6] -> [5] -> [3] -> [1] -
Checking If The Linked List Is Empty Or Not
from linkedit import singlyLinkedList
x = singlyLinkedList(circular=True)
print(x.isEmpty())
Output
True
Do A Right / Left Shifting
Right Shifting
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True)
print(x)
x >> 3
print(x)
Output
> [6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -
> [9] -> [5] -> [7] -> [6] -> [3] -> [8] -> [1] -
Left Shifting
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True)
print(x)
x << 3
print(x)
Output
> [6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -
> [1] -> [9] -> [5] -> [7] -> [6] -> [3] -> [8] -
Inserting A New Value In The First Of The Linked List Directely Using prepend
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True)
print(x)
x.prepend(0)
print(x)
Output
> [6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -
> [0] -> [6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -
You Can Change From Circular To Non Circular
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True)
print(x)
x.set_non_circular()
print(x)
Output
> [6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -
[6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -> None (NULL)
Changing From Singly To Doubly
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True)
print(x)
x = x.to_doubly()
print(x)
Output
> [6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -
=> [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] <=
Creating A Dictionary From The Linked List
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True)
y = x.to_dict()
print(x)
print(y)
Output
> [6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -
{6: {'current value @ddress': '0x7f2ffda139d0', 'next value': 3, 'next value @ddress': '0x7f2ffda13a90'}, 3: {'current value @ddress': '0x7f2ffda13a90', 'next value': 8, 'next value @ddress': '0x7f2ffda13990'}, 8: {'current value @ddress': '0x7f2ffda13990', 'next value': 1, 'next value @ddress': '0x7f2ffda3c1d0'}, 1: {'current value @ddress': '0x7f2ffda3c1d0', 'next value': 9, 'next value @ddress': '0x7f2ffd81bb90'}, 9: {'current value @ddress': '0x7f2ffd81bb90', 'next value': 5, 'next value @ddress': '0x7f2ffd81b9d0'}, 5: {'current value @ddress': '0x7f2ffd81b9d0', 'next value': 7, 'next value @ddress': '0x7f2ffd81bcd0'}, 7: {'current value @ddress': '0x7f2ffd81bcd0', 'next value': 6, 'next value @ddress': '0x7f2ffda139d0'}}
Advanced Usage
You Can Loop Over All Linked List Values With A Time Complexity Of O(n)
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7])
node = x.node(0)
for _ in range(len(x)):
print(f"[{node.get_data()}]", end=" -> None\n" if node == x.tail else " -> ")
node = node.next_node()
Output
[6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -> None
You Can Create A Dict Of Nodes Objects From The Linked List
from linkedit import singlyLinkedList
x = singlyLinkedList([6, 3, 8, 1, 9, 5, 7])
nodes_object_list = x.to_dict(node=True)
print(nodes_object_list)
Output
{6: {'current node': <linkedit.singlyLinkedListNode object at 0x7f0b6d613c10>, 'next node value': 3, 'next node': <linkedit.singlyLinkedListNode object at 0x7f0b6d613c90>}, 3: {'current node': <linkedit.singlyLinkedListNode object at 0x7f0b6d613c90>, 'next node value': 8, 'next node': <linkedit.singlyLinkedListNode object at 0x7f0b6d613c50>}, 8: {'current node': <linkedit.singlyLinkedListNode object at 0x7f0b6d613c50>, 'next node value': 1, 'next node': <linkedit.singlyLinkedListNode object at 0x7f0b6d63c450>}, 1: {'current node': <linkedit.singlyLinkedListNode object at 0x7f0b6d63c450>, 'next node value': 9, 'next node': <linkedit.singlyLinkedListNode object at 0x7f0b6d41bd10>}, 9: {'current node': <linkedit.singlyLinkedListNode object at 0x7f0b6d41bd10>, 'next node value': 5, 'next node': <linkedit.singlyLinkedListNode object at 0x7f0b6d41bb50>}, 5: {'current node': <linkedit.singlyLinkedListNode object at 0x7f0b6d41bb50>, 'next node value': 7, 'next node': <linkedit.singlyLinkedListNode object at 0x7f0b6d41be50>}, 7: {'current node': <linkedit.singlyLinkedListNode object at 0x7f0b6d41be50>, 'next node value': None, 'next node': None}}
For Non Circular Doubly Linked List
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7])
print(x)
Output
None (NULL) <- [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] -> None (NULL)
With All Nodes Details
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7], detail=True)
print(x)
Output
โโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโ
โ Previous Value โ Previous Value @ddress โ Current Value โ Current Value @ddress โ Next Value โ Next Value @ddress โ
โโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโก
โ โ โ None (NULL) โ 0x959cc0 (nil/0x0) โ โ โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ None (NULL) โ 0x959cc0 (nil/0x0) โ 6 โ 0x7effd8613950 โ 3 โ 0x7effd8613990 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 6 โ 0x7effd8613950 โ 3 โ 0x7effd8613990 โ 8 โ 0x7effd86139d0 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 3 โ 0x7effd8613990 โ 8 โ 0x7effd86139d0 โ 1 โ 0x7effd863c110 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 8 โ 0x7effd86139d0 โ 1 โ 0x7effd863c110 โ 9 โ 0x7effd845bd10 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 1 โ 0x7effd863c110 โ 9 โ 0x7effd845bd10 โ 5 โ 0x7effd845bb50 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 9 โ 0x7effd845bd10 โ 5 โ 0x7effd845bb50 โ 7 โ 0x7effd845be50 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 5 โ 0x7effd845bb50 โ 7 โ 0x7effd845be50 โ None (NULL) โ 0x959cc0 (nil/0x0) โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ โ โ None (NULL) โ 0x959cc0 (nil/0x0) โ โ โ
โโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโ
With Dec(10) Base
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7], detail=True, base=10)
print(x)
Output
โโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโ
โ Previous Value โ Previous Value @ddress โ Current Value โ Current Value @ddress โ Next Value โ Next Value @ddress โ
โโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโก
โ โ โ None (NULL) โ 9804992 (nil/0) โ โ โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ None (NULL) โ 9804992 (nil/0) โ 6 โ 140107643451856 โ 3 โ 140107643451984 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 6 โ 140107643451856 โ 3 โ 140107643451984 โ 8 โ 140107643451920 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 3 โ 140107643451984 โ 8 โ 140107643451920 โ 1 โ 140107643617424 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 8 โ 140107643451920 โ 1 โ 140107643617424 โ 9 โ 140107641601424 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 1 โ 140107643617424 โ 9 โ 140107641601424 โ 5 โ 140107641600976 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 9 โ 140107641601424 โ 5 โ 140107641600976 โ 7 โ 140107641601744 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 5 โ 140107641600976 โ 7 โ 140107641601744 โ None (NULL) โ 9804992 (nil/0) โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ โ โ None (NULL) โ 9804992 (nil/0) โ โ โ
โโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโ
Adding The Items In An Orderly Ascending And Descending Manner
ASC
from linkedit import doublyLinkedList
x = doublyLinkedList()
x.add(6)
x.add(3)
x.add(8)
x.add(1)
x.add(9)
x.add(5)
x.add(7)
print(x)
Output
None (NULL) <- [1] <=> [3] <=> [5] <=> [6] <=> [7] <=> [8] <=> [9] -> None (NULL)
DESC
from linkedit import doublyLinkedList
x = doublyLinkedList(reverse=True)
x.add(6)
x.add(3)
x.add(8)
x.add(1)
x.add(9)
x.add(5)
x.add(7)
print(x)
Output
None (NULL) <- [9] <=> [8] <=> [7] <=> [6] <=> [5] <=> [3] <=> [1] -> None (NULL)
Checking If The Linked List Is Empty Or Not
from linkedit import doublyLinkedList
x = doublyLinkedList()
print(x.isEmpty())
Output
True
Do Right / Left Shifting
Right Shifting
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7])
print(x)
x >> 3
print(x)
Output
None (NULL) <- [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] -> None (NULL)
None (NULL) <- [9] <=> [5] <=> [7] <=> [6] <=> [3] <=> [8] <=> [1] -> None (NULL)
Left Shifting
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7])
print(x)
x << 3
print(x)
Output
None (NULL) <- [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] -> None (NULL)
None (NULL) <- [1] <=> [9] <=> [5] <=> [7] <=> [6] <=> [3] <=> [8] -> None (NULL)
Inserting A New Value In The First Of Linked List Directely Using prepend
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7])
print(x)
x.prepend(0)
print(x)
Output
None (NULL) <- [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] -> None (NULL)
None (NULL) <- [0] <=> [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] -> None (NULL)
Changing From Non Circular To Circular
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7])
print(x)
x.set_circular()
print(x)
Output
None (NULL) <- [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] -> None (NULL)
=> [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] <=
You Can Change From Doubly To Singly
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7])
print(x)
x = x.to_singly()
print(x)
Output
None (NULL) <- [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] -> None (NULL)
[6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -> None (NULL)
Creating A Dictionary From The Linked List
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7])
y = x.to_dict()
print(x)
print(y)
Output
None (NULL) <- [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] -> None (NULL)
{6: {'current value @ddress': '0x7fb9c6117990', 'next value': 3, 'next value @ddress': '0x7fb9c6117a90'}, 3: {'current value @ddress': '0x7fb9c6117a90', 'next value': 8, 'next value @ddress': '0x7fb9c6117ad0'}, 8: {'current value @ddress': '0x7fb9c6117ad0', 'next value': 1, 'next value @ddress': '0x7fb9c6140250'}, 1: {'current value @ddress': '0x7fb9c6140250', 'next value': 9, 'next value @ddress': '0x7fb9c5f23b10'}, 9: {'current value @ddress': '0x7fb9c5f23b10', 'next value': 5, 'next value @ddress': '0x7fb9c5f23950'}, 5: {'current value @ddress': '0x7fb9c5f23950', 'next value': 7, 'next value @ddress': '0x7fb9c5f23c50'}, 7: {'current value @ddress': '0x7fb9c5f23c50', 'next value': None, 'next value @ddress': '0x959cc0'}}
For Circular Doubly Linked List
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True)
print(x)
Output
=> [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] <=
With All Nodes Details
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True, detail=True)
print(x)
Output
โโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโ
โ Previous Value โ Previous Value @ddress โ Current Value โ Current Value @ddress โ Next Value โ Next Value @ddress โ
โโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโก
โ 7 โ 0x7ff7a725be10 โ 6 โ 0x7ff7a7413ad0 โ 3 โ 0x7ff7a7413b50 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 6 โ 0x7ff7a7413ad0 โ 3 โ 0x7ff7a7413b50 โ 8 โ 0x7ff7a7413b10 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 3 โ 0x7ff7a7413b50 โ 8 โ 0x7ff7a7413b10 โ 1 โ 0x7ff7a7427fd0 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 8 โ 0x7ff7a7413b10 โ 1 โ 0x7ff7a7427fd0 โ 9 โ 0x7ff7a725bcd0 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 1 โ 0x7ff7a7427fd0 โ 9 โ 0x7ff7a725bcd0 โ 5 โ 0x7ff7a725bb10 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 9 โ 0x7ff7a725bcd0 โ 5 โ 0x7ff7a725bb10 โ 7 โ 0x7ff7a725be10 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 5 โ 0x7ff7a725bb10 โ 7 โ 0x7ff7a725be10 โ 6 โ 0x7ff7a7413ad0 โ
โโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโ
With Dec(10) Base
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True, detail=True, base=10)
print(x)
Output
โโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโ
โ Previous Value โ Previous Value @ddress โ Current Value โ Current Value @ddress โ Next Value โ Next Value @ddress โ
โโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโก
โ 7 โ 140070320684368 โ 6 โ 140070322534992 โ 3 โ 140070322535184 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 6 โ 140070322534992 โ 3 โ 140070322535184 โ 8 โ 140070322534928 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 3 โ 140070322535184 โ 8 โ 140070322534928 โ 1 โ 140070322700432 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 8 โ 140070322534928 โ 1 โ 140070322700432 โ 9 โ 140070320684048 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 1 โ 140070322700432 โ 9 โ 140070320684048 โ 5 โ 140070320683600 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 9 โ 140070320684048 โ 5 โ 140070320683600 โ 7 โ 140070320684368 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ 5 โ 140070320683600 โ 7 โ 140070320684368 โ 6 โ 140070322534992 โ
โโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโ
Adding The Items In An Orderly Ascending And Descending Manner
ASC
from linkedit import doublyLinkedList
x = doublyLinkedList(circular=True)
x.add(6)
x.add(3)
x.add(8)
x.add(1)
x.add(9)
x.add(5)
x.add(7)
print(x)
Output
=> [1] <=> [3] <=> [5] <=> [6] <=> [7] <=> [8] <=> [9] <=
DESC
from linkedit import doublyLinkedList
x = doublyLinkedList(circular=True, reverse=True)
x.add(6)
x.add(3)
x.add(8)
x.add(1)
x.add(9)
x.add(5)
x.add(7)
print(x)
Output
=> [9] <=> [8] <=> [7] <=> [6] <=> [5] <=> [3] <=> [1] <=
Checking If The Linked List Is Empty Or Not
from linkedit import doublyLinkedList
x = doublyLinkedList(circular=True)
print(x.isEmpty())
Output
True
Do Right / Left Shifting
Right Shifting
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True)
print(x)
x >> 3
print(x)
Output
=> [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] <=
=> [9] <=> [5] <=> [7] <=> [6] <=> [3] <=> [8] <=> [1] <=
Left Shifting
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True)
print(x)
x << 3
print(x)
Output
=> [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] <=
=> [1] <=> [9] <=> [5] <=> [7] <=> [6] <=> [3] <=> [8] <=
Inserting A New Value In The First Of Linked List Directely Using prepend
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True)
print(x)
x.prepend(0)
print(x)
Output
=> [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] <=
=> [0] <=> [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] <=
Changing From Circular To Non Circular
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True)
print(x)
x.set_non_circular()
print(x)
Output
=> [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] <=
None (NULL) <- [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] -> None (NULL)
You Can Change From Doubly To Singly
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True)
print(x)
x = x.to_singly()
print(x)
Output
=> [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] <=
> [6] -> [3] -> [8] -> [1] -> [9] -> [5] -> [7] -
Creating A Dictionary From The Linked List
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7], circular=True)
y = x.to_dict()
print(x)
print(y)
Output
=> [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] <=
{6: {'current value @ddress': '0x7f5366a139d0', 'next value': 3, 'next value @ddress': '0x7f5366a13a90'}, 3: {'current value @ddress': '0x7f5366a13a90', 'next value': 8, 'next value @ddress': '0x7f5366a13990'}, 8: {'current value @ddress': '0x7f5366a13990', 'next value': 1, 'next value @ddress': '0x7f5366a3c1d0'}, 1: {'current value @ddress': '0x7f5366a3c1d0', 'next value': 9, 'next value @ddress': '0x7f536681bb90'}, 9: {'current value @ddress': '0x7f536681bb90', 'next value': 5, 'next value @ddress': '0x7f536681b9d0'}, 5: {'current value @ddress': '0x7f536681b9d0', 'next value': 7, 'next value @ddress': '0x7f536681bcd0'}, 7: {'current value @ddress': '0x7f536681bcd0', 'next value': 6, 'next value @ddress': '0x7f5366a139d0'}}
Advanced Usage
Looping Over All Linked List Values With A Time Complexity Of O(n)
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7])
print("Forward : ")
node = x.node(0)
print("None <- ", end="")
for _ in range(len(x)):
print(f"[{node.get_data()}]", end=" -> None\n" if node == x.tail else " <=> ")
node = node.next_node()
print("Backward : ")
node = x.node(-1)
print("None <- ", end="")
for _ in range(len(x)):
print(f"[{node.get_data()}]", end=" -> None\n" if node == x.head else " <=> ")
node = node.prev_node()
Output
Forward :
None <- [6] <=> [3] <=> [8] <=> [1] <=> [9] <=> [5] <=> [7] -> None
Backward :
None <- [7] <=> [5] <=> [9] <=> [1] <=> [8] <=> [3] <=> [6] -> None
You Can Create A Dict Of Nodes Objects From The Linked List
from linkedit import doublyLinkedList
x = doublyLinkedList([6, 3, 8, 1, 9, 5, 7])
nodes_object_list = x.to_dict(node=True)
print(nodes_object_list)
Output
{6: {'prev node value': None, 'prev node @ddress': None, 'current node': <linkedit.doublyLinkedListNode object at 0x7ff5514d79d0>, 'next node value': 3, 'next node': <linkedit.doublyLinkedListNode object at 0x7ff5514d7a50>}, 3: {'prev node value': 6, 'prev node @ddress': <linkedit.doublyLinkedListNode object at 0x7ff5514d79d0>, 'current node': <linkedit.doublyLinkedListNode object at 0x7ff5514d7a50>, 'next node value': 8, 'next node': <linkedit.doublyLinkedListNode object at 0x7ff5514d7a10>}, 8: {'prev node value': 3, 'prev node @ddress': <linkedit.doublyLinkedListNode object at 0x7ff5514d7a50>, 'current node': <linkedit.doublyLinkedListNode object at 0x7ff5514d7a10>, 'next node value': 1, 'next node': <linkedit.doublyLinkedListNode object at 0x7ff55128fe50>}, 1: {'prev node value': 8, 'prev node @ddress': <linkedit.doublyLinkedListNode object at 0x7ff5514d7a10>, 'current node': <linkedit.doublyLinkedListNode object at 0x7ff55128fe50>, 'next node value': 9, 'next node': <linkedit.doublyLinkedListNode object at 0x7ff55128fc90>}, 9: {'prev node value': 1, 'prev node @ddress': <linkedit.doublyLinkedListNode object at 0x7ff55128fe50>, 'current node': <linkedit.doublyLinkedListNode object at 0x7ff55128fc90>, 'next node value': 5, 'next node': <linkedit.doublyLinkedListNode object at 0x7ff55128ff90>}, 5: {'prev node value': 9, 'prev node @ddress': <linkedit.doublyLinkedListNode object at 0x7ff55128fc90>, 'current node': <linkedit.doublyLinkedListNode object at 0x7ff55128ff90>, 'next node value': 7, 'next node': <linkedit.doublyLinkedListNode object at 0x7ff55128fed0>}, 7: {'prev node value': 5, 'prev node @ddress': <linkedit.doublyLinkedListNode object at 0x7ff55128ff90>, 'current node': <linkedit.doublyLinkedListNode object at 0x7ff55128fed0>, 'next node value': None, 'next node': None}}
Important Note
You can use all list methods with singly / doubly linked list sush as [append, clear, copy, count, extand, insert, index, pop, remove, reverse, sort], and all operations you can do with a list can do with this linked list.
For Non Circular Orthogonal Linked List
from linkedit import orthogonalLinkedList
x = orthogonalLinkedList([[6, 3, 8], [1, 9, 5], [7, 2, 4]])
print(x)
Output
โโโโโโโโคโโโโโโโคโโโโโโโคโโโโโโโคโโโโโโโ
โ โ None โ None โ None โ โ
โโโโโโโโผโโโโโโโผโโโโโโโผโโโโโโโผโโโโโโโค
โ None โ 6 โ 3 โ 8 โ None โ
โโโโโโโโผโโโโโโโผโโโโโโโผโโโโโโโผโโโโโโโค
โ None โ 1 โ 9 โ 5 โ None โ
โโโโโโโโผโโโโโโโผโโโโโโโผโโโโโโโผโโโโโโโค
โ None โ 7 โ 2 โ 4 โ None โ
โโโโโโโโผโโโโโโโผโโโโโโโผโโโโโโโผโโโโโโโค
โ โ None โ None โ None โ โ
โโโโโโโโงโโโโโโโงโโโโโโโงโโโโโโโงโโโโโโโ
With All Nodes Details
from linkedit import orthogonalLinkedList
x = orthogonalLinkedList([[6, 3, 8], [1, 9, 5], [7, 2, 4]], detail=True)
print(x)
Output
โโโโโโโโคโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโคโโโโโโโโโคโโโโโโโโโโโโโโโโโคโโโโโโโโโคโโโโโโโโโโโโโโโโโ
โ Up โ Up @ โ Previous โ Previous @ โ Current โ Current @ โ Down โ Down @ โ Next โ Next @ โ
โโโโโโโโชโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโชโโโโโโโโโชโโโโโโโโโโโโโโโโโชโโโโโโโโโชโโโโโโโโโโโโโโโโโก
โ None โ 0x959cc0 โ None โ 0x959cc0 โ 6 โ 0x7f20d0213250 โ 1 โ 0x7f20d0213cd0 โ 3 โ 0x7f20d0213c50 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ None โ 0x959cc0 โ 6 โ 0x7f20d0213250 โ 3 โ 0x7f20d0213c50 โ 9 โ 0x7f20d023c090 โ 8 โ 0x7f20d0213c90 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ None โ 0x959cc0 โ 3 โ 0x7f20d0213c50 โ 8 โ 0x7f20d0213c90 โ 5 โ 0x7f20d005bcd0 โ None โ 0x959cc0 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ 6 โ 0x7f20d0213250 โ None โ 0x959cc0 โ 1 โ 0x7f20d0213cd0 โ 7 โ 0x7f20d005bb10 โ 9 โ 0x7f20d023c090 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ 3 โ 0x7f20d0213c50 โ 1 โ 0x7f20d0213cd0 โ 9 โ 0x7f20d023c090 โ 2 โ 0x7f20d005be10 โ 5 โ 0x7f20d005bcd0 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ 8 โ 0x7f20d0213c90 โ 9 โ 0x7f20d023c090 โ 5 โ 0x7f20d005bcd0 โ 4 โ 0x7f20d005bd50 โ None โ 0x959cc0 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ 1 โ 0x7f20d0213cd0 โ None โ 0x959cc0 โ 7 โ 0x7f20d005bb10 โ None โ 0x959cc0 โ 2 โ 0x7f20d005be10 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ 9 โ 0x7f20d023c090 โ 7 โ 0x7f20d005bb10 โ 2 โ 0x7f20d005be10 โ None โ 0x959cc0 โ 4 โ 0x7f20d005bd50 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ 5 โ 0x7f20d005bcd0 โ 2 โ 0x7f20d005be10 โ 4 โ 0x7f20d005bd50 โ None โ 0x959cc0 โ None โ 0x959cc0 โ
โโโโโโโโงโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโงโโโโโโโโโงโโโโโโโโโโโโโโโโโงโโโโโโโโโงโโโโโโโโโโโโโโโโโ
For Circular Orthogonal Linked List
from linkedit import orthogonalLinkedList
x = orthogonalLinkedList([[6, 3, 8], [1, 9, 5], [7, 2, 4]], circular=True)
print(x)
Output
โโโโโคโโโโคโโโโ
โ 6 โ 3 โ 8 โ
โโโโโผโโโโผโโโโค
โ 1 โ 9 โ 5 โ
โโโโโผโโโโผโโโโค
โ 7 โ 2 โ 4 โ
โโโโโงโโโโงโโโโ
with All Nodes Details
from linkedit import orthogonalLinkedList
x = orthogonalLinkedList([[6, 3, 8], [1, 9, 5], [7, 2, 4]], circular=True, detail=True)
print(x)
Output
โโโโโโโโคโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโคโโโโโโโโโคโโโโโโโโโโโโโโโโโคโโโโโโโโโคโโโโโโโโโโโโโโโโโ
โ Up โ Up @ โ Previous โ Previous @ โ Current โ Current @ โ Down โ Down @ โ Next โ Next @ โ
โโโโโโโโชโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโชโโโโโโโโโชโโโโโโโโโโโโโโโโโชโโโโโโโโโชโโโโโโโโโโโโโโโโโก
โ 7 โ 0x7f01e6153ad0 โ 8 โ 0x7f01e6317cd0 โ 6 โ 0x7f01e6316250 โ 1 โ 0x7f01e6317d10 โ 3 โ 0x7f01e6317c90 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ 2 โ 0x7f01e6153dd0 โ 6 โ 0x7f01e6316250 โ 3 โ 0x7f01e6317c90 โ 9 โ 0x7f01e632bfd0 โ 8 โ 0x7f01e6317cd0 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ 4 โ 0x7f01e6153d10 โ 3 โ 0x7f01e6317c90 โ 8 โ 0x7f01e6317cd0 โ 5 โ 0x7f01e6153c90 โ 6 โ 0x7f01e6316250 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ 6 โ 0x7f01e6316250 โ 5 โ 0x7f01e6153c90 โ 1 โ 0x7f01e6317d10 โ 7 โ 0x7f01e6153ad0 โ 9 โ 0x7f01e632bfd0 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ 3 โ 0x7f01e6317c90 โ 1 โ 0x7f01e6317d10 โ 9 โ 0x7f01e632bfd0 โ 2 โ 0x7f01e6153dd0 โ 5 โ 0x7f01e6153c90 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ 8 โ 0x7f01e6317cd0 โ 9 โ 0x7f01e632bfd0 โ 5 โ 0x7f01e6153c90 โ 4 โ 0x7f01e6153d10 โ 1 โ 0x7f01e6317d10 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ 1 โ 0x7f01e6317d10 โ 4 โ 0x7f01e6153d10 โ 7 โ 0x7f01e6153ad0 โ 6 โ 0x7f01e6316250 โ 2 โ 0x7f01e6153dd0 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ 9 โ 0x7f01e632bfd0 โ 7 โ 0x7f01e6153ad0 โ 2 โ 0x7f01e6153dd0 โ 3 โ 0x7f01e6317c90 โ 4 โ 0x7f01e6153d10 โ
โโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ 5 โ 0x7f01e6153c90 โ 2 โ 0x7f01e6153dd0 โ 4 โ 0x7f01e6153d10 โ 8 โ 0x7f01e6317cd0 โ 7 โ 0x7f01e6153ad0 โ
โโโโโโโโงโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโงโโโโโโโโโงโโโโโโโโโโโโโโโโโงโโโโโโโโโงโโโโโโโโโโโโโโโโโ
Advanced Usage
from linkedit import orthogonalLinkedList
x = orthogonalLinkedList([[6, 3, 8], [1, 9, 5], [7, 2, 4]])
print("Printing All Data Using x.node : ")
for i in range(len(x.node)):
for j in range(len(x.node[i])):
print(x.node[i][j].get_data())
print("Printing All Data Using x.node And x.shape : ")
for i in range(x.shape[0]):
for j in range(x.shape[1]):
print(x.node[i][j].get_data())
center = x.node[1][1]
print(f"All Neighbors Of The Center Node {center.get_data()} : ")
print(f"up : {center.up_node().get_data()}")
print(f"prev : {center.prev_node().get_data()}")
print(f"down : {center.down_node().get_data()}")
print(f"next : {center.next_node().get_data()}")
Output
Printing All Data Using x.node :
6
3
8
1
9
5
7
2
4
Printing All Data Using x.node And x.shape :
6
3
8
1
9
5
7
2
4
All Neighbors Of The Center Node 9 :
up : 3
prev : 1
down : 2
next : 5
License
This project is licensed under the MIT LICENSE - see the LICENSE for more details.