From 25237f885ead17cbc0b966e8a6f69c3a474be6ad Mon Sep 17 00:00:00 2001 From: Jakob Cornell Date: Tue, 15 Dec 2020 00:37:40 -0600 Subject: [PATCH] Cleanup and test suite bug fix --- doc.tex | 7 ++---- impl/algorithms/dijkstra/java/Usage.java | 2 -- impl/algorithms/hull-2d/java/Usage.java | 32 ++++++++++-------------- impl/algorithms/hull-2d/java/makefile | 2 +- latex/algorithms/hull-2d.tex | 18 ++++++------- latex/structures/disjoint-sets.tex | 2 +- 6 files changed, 26 insertions(+), 37 deletions(-) diff --git a/doc.tex b/doc.tex index 0f80d80..62da2f4 100644 --- a/doc.tex +++ b/doc.tex @@ -5,7 +5,6 @@ \usepackage{parskip} % replaces paragraph indentation with vertical space \usepackage{float} % used for captions on code listings \usepackage{ifthen} % for conditional compilation -\usepackage[toc,page]{appendix} \usepackage[bookmarks]{hyperref} % for PDF navigation features \newcommand{\ProjRootPrefix}{..} @@ -46,8 +45,6 @@ \input{\ProjRootPrefix/latex/algorithms/kruskals.tex} \RefBreak - \begin{appendix} - \section{Data Structures} - \input{\ProjRootPrefix/latex/structures/disjoint-sets.tex} - \end{appendix} + \section{Data Structures} + \input{\ProjRootPrefix/latex/structures/disjoint-sets.tex} \end{document} diff --git a/impl/algorithms/dijkstra/java/Usage.java b/impl/algorithms/dijkstra/java/Usage.java index ebf88bb..bb0561d 100644 --- a/impl/algorithms/dijkstra/java/Usage.java +++ b/impl/algorithms/dijkstra/java/Usage.java @@ -1,5 +1,3 @@ -import java.util.Collections; - public class Usage { public static void main(String[] args) { Graph graph = new Graph(); diff --git a/impl/algorithms/hull-2d/java/Usage.java b/impl/algorithms/hull-2d/java/Usage.java index e045ee6..2747357 100644 --- a/impl/algorithms/hull-2d/java/Usage.java +++ b/impl/algorithms/hull-2d/java/Usage.java @@ -1,21 +1,15 @@ -import java.util.*; +Hull.Point a = new Hull.Point(0, 3); +Hull.Point b = new Hull.Point(-2, 2); +Hull.Point c = new Hull.Point(1, -6); -public class Usage { - public static void main(String[] args) { - Hull.Point a = new Hull.Point(0, 3); - Hull.Point b = new Hull.Point(-2, 2); - Hull.Point c = new Hull.Point(1, -6); +// construct a set of points for input +Set points = new HashSet<>(Arrays.asList(new Hull.Point[] {a, b, c})); +// or manually: +Set points2 = new HashSet<>(); +points2.add(a); +points2.add(b); +points2.add(c); - // construct a set of points for input - Set points = new HashSet<>(Arrays.asList(new Hull.Point[] {a, b, c})); - // or manually: - Set points2 = new HashSet<>(); - points2.add(a); - points2.add(b); - points2.add(c); - - List out = Hull.hull(points); - System.out.println(out.get(0) == c); - System.out.println(out.contains(b)); - } -} +List out = Hull.hull(points); +System.out.println(out.get(0) == c); +System.out.println(out.contains(b)); diff --git a/impl/algorithms/hull-2d/java/makefile b/impl/algorithms/hull-2d/java/makefile index e950b22..28a44a1 100644 --- a/impl/algorithms/hull-2d/java/makefile +++ b/impl/algorithms/hull-2d/java/makefile @@ -7,4 +7,4 @@ test: output/Test.class output/Test.class: $(SOURCES) @mkdir -p output - javac -d output Test.java Usage.java + javac -d output Test.java diff --git a/latex/algorithms/hull-2d.tex b/latex/algorithms/hull-2d.tex index 2f6f010..8736989 100644 --- a/latex/algorithms/hull-2d.tex +++ b/latex/algorithms/hull-2d.tex @@ -9,15 +9,6 @@ The implementations here use a technique called Graham scan to compute the convex hull with time complexity $O(n \log n)$, where $n$ is the number of input points. The output points are ordered: the bottom-most (and then leftmost) point appears first, then the remaining hull points in counterclockwise order. - \TopicSubHeader{Java} - - \centerline{\texttt{Hull.java}} - \inputminted{java}{\ThisImpl/java/Hull.java} - - This may be used as follows: - - \inputminted{java}{\ThisImpl/java/Usage.java} - \TopicSubHeader{Python 3} \inputminted{python}{\ThisImpl/python3/hull.py} @@ -27,4 +18,13 @@ A sample usage: \inputminted{python}{\ThisImpl/python3/usage.py} + + \TopicSubHeader{Java} + + \centerline{\texttt{Hull.java}} + \inputminted{java}{\ThisImpl/java/Hull.java} + + This may be used as follows: + + \inputminted{java}{\ThisImpl/java/Usage.java} } diff --git a/latex/structures/disjoint-sets.tex b/latex/structures/disjoint-sets.tex index 768a125..80467c5 100644 --- a/latex/structures/disjoint-sets.tex +++ b/latex/structures/disjoint-sets.tex @@ -15,7 +15,7 @@ \inputminted{python}{\ThisImpl/python3/usage.py} The values in the sets may be of any type, as long as they are hashable. The data - structures uses hashing and equality testing to locate nodes. Generally, this means you + structure uses hashing and equality testing to locate nodes. Generally, this means you can safely use immutable built-in types or your own custom object types as values in the sets. -- 2.30.2