summaryrefslogtreecommitdiffstats
path: root/Algorithms/Part-I/3-Collinear
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-03-11 16:19:11 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2013-11-15 17:38:44 +0100
commitbb98d03e7fb86ea37d0e275a041420619a5ca521 (patch)
tree86e96b955c04c2f0030d829844c9c854eac972ae /Algorithms/Part-I/3-Collinear
parent1a84b361543a750755b72fbf6cb9f058e434fd36 (diff)
downloadcoursera-bb98d03e7fb86ea37d0e275a041420619a5ca521.zip
coursera-bb98d03e7fb86ea37d0e275a041420619a5ca521.tar.gz
Algorithms-I : 3-Collinear: cosmetic
Diffstat (limited to 'Algorithms/Part-I/3-Collinear')
-rw-r--r--Algorithms/Part-I/3-Collinear/Fast.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/Algorithms/Part-I/3-Collinear/Fast.java b/Algorithms/Part-I/3-Collinear/Fast.java
index 5d6ad48..6d9dcac 100644
--- a/Algorithms/Part-I/3-Collinear/Fast.java
+++ b/Algorithms/Part-I/3-Collinear/Fast.java
@@ -41,7 +41,8 @@ public class Fast
if (other == null) return false;
if (other.getClass() != this.getClass()) return false;
Segment s = (Segment) other;
- if ((pts[0].compareTo(s.pts[0]) == 0) || (pts[pts.length - 1].compareTo(s.pts[s.pts.length - 1]) == 0))
+ if ((pts[0].compareTo(s.pts[0]) == 0)
+ || (pts[pts.length - 1].compareTo(s.pts[s.pts.length - 1]) == 0))
return true;
return false;
}
@@ -69,8 +70,6 @@ public class Fast
Point ref = pts[i];
Point[] others = new Point[n];
- ref.draw();
-
for (int j = 0, k = i + 1; j < n; j++, k++)
others[j] = pts[k];
@@ -88,7 +87,8 @@ public class Fast
{
if ((start != -1) && ((j - start) > 2))
{
- Segment seg = new Segment(ref, others, start, (j - start + 1));
+ Segment seg = new Segment(ref, others,
+ start, (j - start + 1));
if (!segments.contains(seg))
segments.add(seg);
}
@@ -120,7 +120,9 @@ public class Fast
for (int i = 0; i < n; i++)
{
pts[i] = new Point(in.readInt(), in.readInt());
+ pts[i].draw();
}
+ Arrays.sort(pts);
// Stopwatch w = new Stopwatch();