A simple Python library for creating linked lists and performing operations.
Project description
LLlib - A Linked List Library for Python
LLlib is a simple Python library for creating List Nodes / Linked Lists and performing dense operations (reverse in k-groups, swap in even length groups), design subsidiary structures (LRU/LFU caches, text editors, etc) and build derived classes based projects.
© Copyright 2023, All rights reserved to Hans Haller, MSc Graduate Student in Computer Science at Cranfield University, United Kingdom.
Author GitHub: https://github.com/Hnshlr
Python Package Index (PyPI): https://pypi.org/project/LLlib/
Context
Linked lists are a fundamental data structure in computer science. They are used to store data in a linear fashion, and are often used to implement other data structures such as stacks, queues, and trees. Linked lists are also used to implement file systems, hash tables, and adjacency lists.
The objective of this package/library (tbd later) is to provide a simple and easy to use interface for creating linked lists and performing simple or complex operations on them. The library is written in Python, and is designed to be used with Python 3.9 or higher.
The core finality of these classes is for anyone to create their own class derived from the LinkedList class, and implement their architectures based on the methods provided by the library.
Installation
The LLlib library is available on PyPI (Python Package Index, the official third-party software repository for Python), and can be installed using pip:
$ pip install LLlib
Documentation
The documentation for the LLlib library is currently under development. The documentation will be available on Read the Docs, and will be accessible through the LLlib PyPI page.
Usage
Import the Package
$ python
>>> from LLlib import *
List Nodes
The LLlib library provides a ListNode class for creating list nodes. The ListNode class is a simple class that stores a value and a pointer to the next node in the list. The ListNode class can be used to create a linked list by chaining together multiple ListNode objects.
>>> from LLlib import ListNode
>>> head = ListNode(1, ListNode(2, ListNode(3, ListNode(4, ListNode(5)))))
>>> str(head)
'1 -> 2 -> 3 -> 4 -> 5 -> None'
>>> ListNode.reverse_list_in_k_group(head, k=2)
>>> str(head)
'2 -> 1 -> 4 -> 3 -> 5 -> None'
Ultimately, one may create a class derived from the ListNode class, and implement their own methods and attributes.
As an example, to create a Spotify-like music player, one may create a Song class derived from the ListNode class, and implement their own methods and attributes related to the project at hand.
This class will allow the user to utilize ListNode methods and attributes to manipulate the data more efficiently (e.g. reversing the playlist, shuffling the songs, etc).
Linked Lists
LLlib also provides a LinkedList class for creating linked lists. The LinkedList class is a simple class that stores a pointer to the head of the list. The LinkedList class can be used to create a complete linked lists (of ListNode objects) by chaining together multiple ListNode objects, using data structures such as lists, tuples, sets, dictionaries, etc.
>>> from LLlib import LinkedList
>>> list = [1, 2, 3, 4, 5]
>>> head = LinkedList(list)
>>> str(head)
'1 -> 2 -> 3 -> 4 -> 5 -> None'
>>> jagged = [[1, 2, 3], [4, 5, [6, 7]], [8, 9, 10, 11]]
>>> head = LinkedList(jagged)
>>> str(head)
'1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10 -> 11 -> None'
For more examples, see the EXAMPLES.md markdown file.
Acknowledgements
The LLlib library was developed by Hans Haller, MSc Graduate Student in Computer Science at Cranfield University, United Kingdom. Most of the code used is truly unique, and was developed by the author.
Most of the functions' concepts and ideas were inspired by Leetcode and HackerRank problems. All solutions were developed by the author, and in no way were copied from other sources.
License
This project is licensed under the MIT License.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Library.
Copyright (c) 2023-2024, All rights reserved to Hans Haller.
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 LLlib-0.0.2.tar.gz.
File metadata
- Download URL: LLlib-0.0.2.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9416b16d3d57a2798e6d46e3c9c121b5e8c31dfc3ab9b5154ddf2f41819016e7
|
|
| MD5 |
515bca880112969a765a2a64064f569e
|
|
| BLAKE2b-256 |
9126df2fefe69116dd0e31ed7037e15d90d8b384040292ea8718cbeb6f6113b4
|
File details
Details for the file LLlib-0.0.2-py3-none-any.whl.
File metadata
- Download URL: LLlib-0.0.2-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb1115c1e1b75ef99011eefeb959d48abecaa6334fc77dc32a4f0925c1fb848f
|
|
| MD5 |
700180c481e75a0a1cc7c80251031f49
|
|
| BLAKE2b-256 |
fb85ec833c7613c56ed7845622be8de5418f250d73972eb706bd74c3f584f7bb
|