method-emitter 0.1.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: method-emitter
3
+ Version: 0.1.0
4
+ Summary: Prints Java data structure method snippets from one public function.
5
+ Requires-Python: >=3.8
6
+ Description-Content-Type: text/markdown
7
+
8
+ # method-emitter
9
+
10
+ method-emitter has one public function: emit_code(). Calling it prints the Java queue and stack method snippets transcribed from the supplied handout.
11
+
12
+ ## Install
13
+
14
+ python -m pip install method-emitter
15
+
16
+ ## Use
17
+
18
+ from method_emitter import emit_code
19
+ emit_code()
20
+
21
+ The snippets expect to be placed inside their corresponding generic linked queue or stack classes. The queue code uses QueueNode, frontLink, and rearLink; the stack code uses StackNode and topLink. The removeAll and countOccurrences methods call Objects.equals, so the containing Java source needs import java.util.Objects.
@@ -0,0 +1,14 @@
1
+ # method-emitter
2
+
3
+ method-emitter has one public function: emit_code(). Calling it prints the Java queue and stack method snippets transcribed from the supplied handout.
4
+
5
+ ## Install
6
+
7
+ python -m pip install method-emitter
8
+
9
+ ## Use
10
+
11
+ from method_emitter import emit_code
12
+ emit_code()
13
+
14
+ The snippets expect to be placed inside their corresponding generic linked queue or stack classes. The queue code uses QueueNode, frontLink, and rearLink; the stack code uses StackNode and topLink. The removeAll and countOccurrences methods call Objects.equals, so the containing Java source needs import java.util.Objects.
@@ -0,0 +1,13 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "method-emitter"
7
+ version = "0.1.0"
8
+ description = "Prints Java data structure method snippets from one public function."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+
12
+ [tool.setuptools.packages.find]
13
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,82 @@
1
+ """Print the Java data-structure methods included with the package."""
2
+
3
+ __all__ = ["emit_code"]
4
+
5
+
6
+ _SOURCE = '''// Queue Methods
7
+
8
+ // moveFrontToBack()
9
+ public boolean moveFrontToBack() {
10
+ if (frontLink == null || frontLink == rearLink) {
11
+ return false;
12
+ }
13
+
14
+ QueueNode movedLink = frontLink;
15
+ frontLink = frontLink.nextLink;
16
+ movedLink.nextLink = null;
17
+ rearLink.nextLink = movedLink;
18
+ rearLink = movedLink;
19
+ return true;
20
+ }
21
+
22
+ // removeAll(T targetValue)
23
+ public int removeAll(T targetValue) {
24
+ int count = 0;
25
+ QueueNode current = frontLink, previous = null;
26
+
27
+ while (current != null) {
28
+ if (Objects.equals(current.value, targetValue)) {
29
+ if (previous == null)
30
+ frontLink = current.nextLink;
31
+ else
32
+ previous.nextLink = current.nextLink;
33
+ count++;
34
+ } else
35
+ previous = current;
36
+
37
+ current = current.nextLink;
38
+ }
39
+
40
+ rearLink = previous;
41
+ return count;
42
+ }
43
+
44
+ // Stack Methods
45
+
46
+ // countOccurrences(T targetValue)
47
+ public int countOccurrences(T targetValue) {
48
+ int count = 0;
49
+ StackNode current = topLink;
50
+
51
+ while (current != null) {
52
+ if (Objects.equals(current.value, targetValue))
53
+ count++;
54
+ current = current.nextLink;
55
+ }
56
+
57
+ return count;
58
+ }
59
+
60
+ // removeBottom()
61
+ public T removeBottom() {
62
+ if (topLink == null) return null;
63
+
64
+ StackNode current = topLink, previous = null;
65
+
66
+ while (current.nextLink != null) {
67
+ previous = current;
68
+ current = current.nextLink;
69
+ }
70
+
71
+ if (previous == null)
72
+ topLink = null;
73
+ else
74
+ previous.nextLink = null;
75
+ return current.value;
76
+ }
77
+ '''
78
+
79
+
80
+ def emit_code() -> None:
81
+ """Print all queue and stack method snippets."""
82
+ print(_SOURCE, end="")
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: method-emitter
3
+ Version: 0.1.0
4
+ Summary: Prints Java data structure method snippets from one public function.
5
+ Requires-Python: >=3.8
6
+ Description-Content-Type: text/markdown
7
+
8
+ # method-emitter
9
+
10
+ method-emitter has one public function: emit_code(). Calling it prints the Java queue and stack method snippets transcribed from the supplied handout.
11
+
12
+ ## Install
13
+
14
+ python -m pip install method-emitter
15
+
16
+ ## Use
17
+
18
+ from method_emitter import emit_code
19
+ emit_code()
20
+
21
+ The snippets expect to be placed inside their corresponding generic linked queue or stack classes. The queue code uses QueueNode, frontLink, and rearLink; the stack code uses StackNode and topLink. The removeAll and countOccurrences methods call Objects.equals, so the containing Java source needs import java.util.Objects.
@@ -0,0 +1,7 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/method_emitter/__init__.py
4
+ src/method_emitter.egg-info/PKG-INFO
5
+ src/method_emitter.egg-info/SOURCES.txt
6
+ src/method_emitter.egg-info/dependency_links.txt
7
+ src/method_emitter.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ method_emitter