pystlx 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pystlx/linear/__init__.py +0 -0
- pystlx/linear/linked_list.py +72 -0
- pystlx/nonlinear/__init__.py +0 -0
- pystlx-0.0.1.dist-info/METADATA +13 -0
- pystlx-0.0.1.dist-info/RECORD +8 -0
- pystlx-0.0.1.dist-info/WHEEL +5 -0
- pystlx-0.0.1.dist-info/licenses/LICENSE +21 -0
- pystlx-0.0.1.dist-info/top_level.txt +1 -0
|
File without changes
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Node:
|
|
5
|
+
def __init__(self, data):
|
|
6
|
+
self.data = data
|
|
7
|
+
self.next_node = None
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class LinkedList:
|
|
11
|
+
def __init__(self):
|
|
12
|
+
self.head = None
|
|
13
|
+
self.tail = None
|
|
14
|
+
self.len = 0
|
|
15
|
+
|
|
16
|
+
# O(1) with tail, without O(n)
|
|
17
|
+
def append(self, data):
|
|
18
|
+
new_node = Node(data)
|
|
19
|
+
if self.head == None:
|
|
20
|
+
self.head = new_node
|
|
21
|
+
self.tail = self.head
|
|
22
|
+
self.len += 1
|
|
23
|
+
return
|
|
24
|
+
|
|
25
|
+
self.tail.next_node = new_node
|
|
26
|
+
self.tail = new_node
|
|
27
|
+
self.len += 1
|
|
28
|
+
return
|
|
29
|
+
|
|
30
|
+
# O(n), no rebuild
|
|
31
|
+
def insertat(self, data, index):
|
|
32
|
+
if self.len < index:
|
|
33
|
+
raise IndexError("Index out of bound")
|
|
34
|
+
|
|
35
|
+
insert_node = Node(data)
|
|
36
|
+
index_node = self.head # start with head as base node
|
|
37
|
+
|
|
38
|
+
# TODO: handle insert at index 0 (head) - push(data)
|
|
39
|
+
|
|
40
|
+
# get just before node to index node (we can't look backwards)
|
|
41
|
+
for _ in range(index - 1):
|
|
42
|
+
index_node = index_node.next_node
|
|
43
|
+
|
|
44
|
+
tmp_node = index_node.next_node
|
|
45
|
+
index_node.next_node = insert_node
|
|
46
|
+
insert_node.next_node = tmp_node
|
|
47
|
+
self.len += 1
|
|
48
|
+
|
|
49
|
+
def push(self, data): pass # insertat first(head)
|
|
50
|
+
def lpop(self): pass # delete last
|
|
51
|
+
def fpop(self): pass # delete first
|
|
52
|
+
def deleteat(self, index): pass
|
|
53
|
+
|
|
54
|
+
def __str__(self):
|
|
55
|
+
ll_rep = str(self.head.data) # first node
|
|
56
|
+
start = self.head.next_node # next node
|
|
57
|
+
|
|
58
|
+
while(start != None):
|
|
59
|
+
ll_rep += f" -> {start.data}"
|
|
60
|
+
start = start.next_node
|
|
61
|
+
return ll_rep
|
|
62
|
+
|
|
63
|
+
if __name__ == "__main__":
|
|
64
|
+
ll = LinkedList()
|
|
65
|
+
for i in range(1, 11):
|
|
66
|
+
ll.append(i)
|
|
67
|
+
print(ll)
|
|
68
|
+
print(ll.len)
|
|
69
|
+
|
|
70
|
+
ll.insertat(9, 1)
|
|
71
|
+
print(ll)
|
|
72
|
+
print(ll.len)
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pystlx
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Standard Template Library for Python
|
|
5
|
+
Author-email: Prasad Raju G <gls.prasadraju@gmail.com>
|
|
6
|
+
Requires-Python: >=3.14
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
|
|
11
|
+
<div align="center">
|
|
12
|
+
<img src="logo.svg", width="55%">
|
|
13
|
+
</div>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
pystlx/linear/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
pystlx/linear/linked_list.py,sha256=siJooC2lgyxFqkL3FKaq9Z-gfGU0qnGktk-QwcqcP8Y,1618
|
|
3
|
+
pystlx/nonlinear/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
pystlx-0.0.1.dist-info/licenses/LICENSE,sha256=6GLtQg2RY6HkOSBNEtvk53uO1Cx_Q-FKQgRQ2IPzVVs,1070
|
|
5
|
+
pystlx-0.0.1.dist-info/METADATA,sha256=IrB_dz0gKJNAQN3MLNVEeQZ7QRChJ-C8GkT_aVP4FtU,324
|
|
6
|
+
pystlx-0.0.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
7
|
+
pystlx-0.0.1.dist-info/top_level.txt,sha256=E7VsLtNBt8NCVgL2V6JwlYflL_7FVjhcTQoOBk2J23w,7
|
|
8
|
+
pystlx-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Prasad Raju G
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pystlx
|