\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}{..}
\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}
-import java.util.Collections;
-
public class Usage {
public static void main(String[] args) {
Graph graph = new Graph();
-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<Hull.Point> points = new HashSet<>(Arrays.asList(new Hull.Point[] {a, b, c}));
+// or manually:
+Set<Hull.Point> points2 = new HashSet<>();
+points2.add(a);
+points2.add(b);
+points2.add(c);
- // construct a set of points for input
- Set<Hull.Point> points = new HashSet<>(Arrays.asList(new Hull.Point[] {a, b, c}));
- // or manually:
- Set<Hull.Point> points2 = new HashSet<>();
- points2.add(a);
- points2.add(b);
- points2.add(c);
-
- List<Hull.Point> out = Hull.hull(points);
- System.out.println(out.get(0) == c);
- System.out.println(out.contains(b));
- }
-}
+List<Hull.Point> out = Hull.hull(points);
+System.out.println(out.get(0) == c);
+System.out.println(out.contains(b));
output/Test.class: $(SOURCES)
@mkdir -p output
- javac -d output Test.java Usage.java
+ javac -d output Test.java
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}
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}
}
\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.