A comprehensive Python library for Data Structures* and *Algorithms.
Project description
structcore
A comprehensive Python library for Data Structures and Algorithms.
Installation
pip install structcore
Requirement
Python version 3.8 or higher
Available DataStructure
- Linked List
- Stack
- Queue
- Deque
- Binary Search Tree
- Heap (Min/Max)
- Graph (Directed/Undirected)
- Trie
Available Algorithm
Sort Type
- BubbleSort
- SelectionSort
- InsertionSort
- QuickSort
- MergeSort
- HeapSort
Search Type
- LinearSearch
- BinarySearch
- DepthFirstSearch
- BreadthFirstSearch
Linked List
Private Methods
depth_first_search: Used for traversing data using Depth First Search within the Objectbreadth_first_search: Used for traversing data using Breadth First Search within the Object
Public Methods
append: Adds an element to the end (tail) of the Objectappendleft: Adds an element to the front (head) of the Objectinsert: Inserts data at the specified position and existing node at that position shifts to the rightpop: Removes the last element from the Object and returns the removed valuepopleft: Removes the first element from the Object and returns the removed valueremove: Removes the node at the specified index in the Objectfind: Finds the first occurrence of a value and returns the index of that nodereverse: Reorders the nodes in the Object by reversing the order (back to front)min: Find a minimum value in object and returnmax: Find a maximum value in object and returnclear: Removes all nodes from the Object
Python Magic Methods
__getitem__: Accesses a node value within the Object using a key via[]__setitem__: Modifies a node value within the Object using a key via[]__len__: Returns the total number of nodes in the Object__contains__: Checks if a specific value exists in the Object using theinkeyword__iter__: Iterates through each node in the Object by yielding values one by one__eq__: Compares two Objects to determine if they are the same class and have identical nodes__repr__: Displays the Object type when therepr()function is called__bool__: Defines whether the Object evaluates toTrueorFalsewhen used directly in anifstatement__str__: Displays all values within the Object when printed
Stack
Public Methods
push: Adds a new node to the top of the Objectupdate: Modifies the data of the top node in the Objectpeek: Accesses and returns the data of the top node in the Objectpop: Removes the top node from the Objectclear: Removes all nodes from the ObjectisEmpty: Checks whether the Object is empty
Python Magic Methods
__len__: Returns the total number of nodes in the Object__iter__: Iterates through each node in the Object by yielding values one by one__contains__: Checks if a specific value exists in the Object using theinkeyword__eq__: Compares two Objects to determine if they are the same class and have identical nodes__repr__: Displays the Object type when therepr()function is called__bool__: Defines whether the Object evaluates toTrueorFalsewhen used directly in anifstatement__str__: Displays all values within the Object
Queue
Public Methods
enqueue: Adds a node to the front of the Objectdequeue: Removes a node from the rear of the Objectpeek: Views the data at the front of the Objectclear: Removes all nodes from the ObjectisEmpty: Checks whether the Object is empty
Python Magic Methods
__len__: Returns the total number of nodes in the Object__iter__: Iterates through each node in the Object by yielding values one by one__contains__: Checks if a specific value exists in the Object using theinkeyword__eq__: Compares two Objects to determine if they are the same class and have identical nodes__repr__: Displays the Object type when therepr()function is called__bool__: Defines whether the Object evaluates toTrueorFalsewhen used directly in anifstatement__str__: Displays all values within the Object
Deque
Public Methods
append: Adds a node to the rear (tail) of the Objectappendleft: Adds a node to the front (head) of the Objectset_head: Modifies the data of the node at the front of the Objectset_tail: Modifies the data of the node at the rear of the Objectpeek: Views the data of the node at the rear of the Objectpeekleft: Views the data of the node at the front of the Objectpop: Removes the node from the rear of the Objectpopleft: Removes the node from the front of the Objectclear: Removes all nodes from the ObjectisEmpty: Checks whether the Object is empty
Python Magic Methods
__getitem__: Accesses a node's value within the Object using a key via[]__len__: Returns the total number of nodes in the Object__contains__: Checks if a specific value exists in the Object using theinkeyword__iter__: Iterates through each node in the Object by yielding values one by one__eq__: Compares two Objects to determine if they are the same class and have identical nodes__repr__: Displays the Object type when therepr()function is called__bool__: Defines whether the Object evaluates toTrueorFalsewhen used directly in anifstatement__str__: Displays all values within the Object
Binary Search Tree
Private Methods
is_equal: Checks whether two Objects are identical in both data and structureinorder_asc_helper: Helper method to collect data in ascending orderinorder_desc_helper: Helper method to collect data in descending orderdepth_first_search_recursive: Helper method for Depth First Search traversaldepth_first_search: Performs Depth First Search traversal on the Objectbreadth_first_search: Performs Breadth First Search traversal on the Object
Public Methods
insert: Adds a node to the Objectfind: Find a specific value within the Objectinorder_asc: Returns values in ascending orderinorder_desc: Returns values in descending ordermin: Returns the smallest value in the Objectmax: Returns the largest value in the Objectpeek: Views the top node (Root) and returns its valueremove: Removes a specified node from the Objectclear: Removes all nodes from the ObjectisEmpty: Checks whether the Object is empty
Python Magic Methods
__len__: Returns the total number of nodes in the Object__contains__: Checks if a specific value exists in the Object using theinkeyword__eq__: Compares two Objects to determine if they are the same class and have identical values__iter__: Iterates through each value in the Object by yielding values one by one__repr__: Displays the Object type when therepr()function is called__bool__: Defines whether the Object evaluates toTrueorFalsewhen used directly in anifstatement__str__: Displays all values within the Object
Heap
Heap is stored in a Python List.
Values can be accessed using the following formulas, where i is the index of the element:
- parent =
(i - 1) // 2 - left child =
2 * i + 1 - right child =
2 * i + 2Heap is divided into two types: - Min Heap: smallest value at the root
- Max Heap: largest value at the root Both types store data in an array based on the formulas above.
Class Methods
min_heap: Creates a new Min Heap instancemax_heap: Creates a new Max Heap instance
Private Methods
heapify_up: Organizes the Object to maintain heap property after inserting dataheapify_down: Organizes the Object to maintain heap property after removing data
Public Methods
push: Adds data to the Objectpeek: Returns the top value of the Object without removing itmax: Returns the maximum value in the Objectmin: Returns the minimum value in the Objectpop: Removes and returns the top value of the Objectclear: Removes all data from the ObjectisEmpty: Checks whether the Object is empty
Python Magic Methods
__getitem__: Accesses data in the Object using a key via[]__len__: Returns the total number of elements in the Object__iter__: Iterates through each value in the Object by yielding values one by one__eq__: Compares two Objects to determine if they are the same class and have identical values__contains__: Checks if a specific value exists in the Object using theinkeyword__repr__: Displays the Object type when therepr()function is called__bool__: Defines whether the Object evaluates toTrueorFalsewhen used directly in anifstatement__str__: Displays all values within the Object
Graph
Graph is divided into two classes:
- Directed Graph: edges have a direction (one-way)
- Undirected Graph: edges are bidirectional (two-way)
Class Methods
Directed: Creates a new Directed Graph instanceUndirected: Creates a new Undirected Graph instance
Private Methods
depth_first_search: Performs Depth First Search traversal on the Objectbreadth_first_search: Performs Breadth First Search traversal on the Object
Public Methods
add_vertex: Adds a vertex to the Objectadd_edge: Adds an edge to the specified vertexget_neighbors: Retrieves all edges from the specified vertexhas_vertex: Checks whether the specified vertex exists in the Objecthas_edge: Checks whether the specified edge exists in the vertexremove_vertex: Removes the specified vertex from the Objectremove_edge: Removes the specified edge from the vertexclear: Removes all data from the ObjectisEmpty: Checks whether the Object is empty
Python Magic Methods
__getitem__: Accesses values in the Object using a key via[](returns edges from that vertex)__len__: Returns the total number of vertices in the Object__contains__: Checks if a specific vertex exists in the Object using theinkeyword__eq__: Compares two Objects to determine if they are the same class and have identical data__iter__: Iterates through each vertex in the Object by yielding values one by one__repr__: Displays the Object type when therepr()function is called__bool__: Defines whether the Object evaluates toTrueorFalsewhen used directly in anifstatement__str__: Displays all values within the Object
Trie
Private Methods
collect_word: Helper method to collect specific data from the Object and return itremove_helper: Helper method to remove a word without disrupting the Object's structuredepth_first_search: Performs Depth First Search traversal on the Objectdepth_first_search_collect: Helper method for collecting data during Depth First Searchbreadth_first_search: Performs Breadth First Search traversal on the Object
Public Methods
insert: Adds a word to the Objectfind: Find for a specific word in the Objectstarts_with: Checks if any word starts with the given prefix; returnsTrueif foundget_word: Retrieves all words from the Object and returns themget_word_with_prefix: Retrieves all words that start with the given prefix and returns themremove: Removes a specified word from the Objectclear: Removes all data from the ObjectisEmpty: Checks whether the Object is empty
Python Magic Methods
__len__: Returns the total number of words in the Object__contains__: Checks if a specific word exists in the Object using theinkeyword__iter__: Iterates through each word in the Object by yielding values one by one__eq__: Compares two Objects to determine if they are the same class and have identical values__repr__: Displays the Object type when therepr()function is called__bool__: Defines whether the Object evaluates toTrueorFalsewhen used directly in anifstatement__str__: Displays all values within the Object
Sort Type
BubbleSort
Public Function
bubble_sort: Sorts items in the Object using the Bubble Sort Algorithm
SelectionSort
Public Function
selection_sort: Sorts items in the Object using the Selection Sort Algorithm
InsertionSort
Public Function
insertion_sort: Sorts items in the Object using the Insertion Sort Algorithm
QuickSort
Private Functions
__median_of_three: Selects the pivot from the first, middle, and last elements of the partition__quick_sort_in_place: Sorts the Object in-place using recursive partitioning__partition: Rearranges items around the pivot into left and right partitions
Public Function
quick_sort: Sorts items in the Object using the Quick Sort Algorithm
MergeSort
Private Function
__merge: Merges two sorted sublists into a single sorted list
Public Function
merge_sort: Sorts items in the Object using the Merge Sort Algorithm
HeapSort
Public Function
heap_sort: Sorts items in the Object using the Heap Sort Algorithm
Search Type
Binary Search
Public Function
binary_search: Searches for a target value in the Object using the Binary Search Algorithm (requires sorted data)
Breadth First Search
Public Method
breadth_first_search: Searches for a target value in the Object using the Breadth First Search Algorithm
Depth First Search
Public Method
depth_first_search: Searches for a target value in the Object using the Depth First Search Algorithm
Linear Search
Public Function
linear_search: Searches for a target value in the Object using the Linear Search Algorithm
How To Use
import structcore
data = structcore.LinkedList()
data.append(20)
print(data)
message = structcore.Trie()
message.insert("Kuronanod")
print(message.find("Kuronanod"))
data = [2,41,4,2,5,7,4,8744,7,345,7]
sorted_data = structcore.quick_sort(data.copy())
answer = structcore.linear_search(sorted_data,8744)
print(answer)
License
MIT License
Copyright (c) 2026 Kuronanod
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Author
Thawankorn Suwannabon Github : Kuronanod Email : thwalkrsuwrrnbl@gmail.com
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 structcore-1.0.1.tar.gz.
File metadata
- Download URL: structcore-1.0.1.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5dc7dd56fd0b2618a5733e6b8006f2aa2add9229d528d9e2e1287b784726b78
|
|
| MD5 |
5c9573081fc18239dc1d4f0933236cfc
|
|
| BLAKE2b-256 |
d5eb84546cc7bd04988ff2ec509169dfaf0dc4af50d6c5befb8515958ad1af7e
|
Provenance
The following attestation bundles were made for structcore-1.0.1.tar.gz:
Publisher:
publish-to-pypi.yml on Kuronanod/structcore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
structcore-1.0.1.tar.gz -
Subject digest:
d5dc7dd56fd0b2618a5733e6b8006f2aa2add9229d528d9e2e1287b784726b78 - Sigstore transparency entry: 1561733161
- Sigstore integration time:
-
Permalink:
Kuronanod/structcore@354c2326d731deac05ff8d134c9ba7ff560d11e1 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/Kuronanod
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@354c2326d731deac05ff8d134c9ba7ff560d11e1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file structcore-1.0.1-py3-none-any.whl.
File metadata
- Download URL: structcore-1.0.1-py3-none-any.whl
- Upload date:
- Size: 26.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e55d04d96f16bdcb62d067b8bf53cd4a82e1df70f7896c5cf329679873b36318
|
|
| MD5 |
e0ad54b51d42e66d0f05866c9d77f401
|
|
| BLAKE2b-256 |
ffea96333896c1401a2f981da8a67521d615dfcef2ffa0db76d49fe077972967
|
Provenance
The following attestation bundles were made for structcore-1.0.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on Kuronanod/structcore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
structcore-1.0.1-py3-none-any.whl -
Subject digest:
e55d04d96f16bdcb62d067b8bf53cd4a82e1df70f7896c5cf329679873b36318 - Sigstore transparency entry: 1561733403
- Sigstore integration time:
-
Permalink:
Kuronanod/structcore@354c2326d731deac05ff8d134c9ba7ff560d11e1 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/Kuronanod
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@354c2326d731deac05ff8d134c9ba7ff560d11e1 -
Trigger Event:
push
-
Statement type: